|
| 10 Apr 2015 09:24 AM |
Does anyone know how to use the CharacterAdded event in a normal function, and not an anonymous one? I don't know any other way to track a player's character in the workspace upon joining the game besides using this: game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) end) end)
Any other ways I could do it?
I am an owl. |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 09:26 AM |
player.CharacterAdded:connect(characterAdded())
Then have a function named that
Total Posts: 404 ---------- Not Found |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 09:26 AM |
Would the server automatically know what "player" is? I thought you had to like set "player" to some variable.
I am an owl. |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 09:28 AM |
| You do. You can use PlayerAdded. |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 09:28 AM |
I put it into studio mode. This is what it looks like:
function characterAdded() <----I think I did that right. end
player.CharacterAdded:connect(characterAdded())
And at the player, underlined in blue, it says, "Unknown global 'player'"
I am an owl. |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 09:29 AM |
Sorry guys, beginner at scripting here. I don't know everything about functions, yet. :D
I am an owl. |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 09:30 AM |
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(characterAdded()) end) end)
Total Posts: 404 ---------- Not Found |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 09:31 AM |
woops forgot to remove an end)
Total Posts: 404 ---------- Not Found |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 09:33 AM |
Is that a named or anonymous function? :o
I am an owl. |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 09:34 AM |
I just fixed your player variable problem. It's not anonymous
Total Posts: 404 ---------- Not Found |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 09:35 AM |
Ah. But it says that the "characterAdded" in the parentheses is an unknown global variable :o
I am an owl. |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 09:35 AM |
function PlayerAdded(player) function CharacterAdded(character) --stuff here player.CharacterAdded:connect(CharacterAdded) game.Players.PlayerAdded:connect(PlayerAdded) |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 09:36 AM |
| forgot the ends on my post, you get the gist though |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 09:37 AM |
:o I think you did it. Hooray! :D
I am an owl. |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 09:38 AM |
Oh and, does C0 and C1 still exist in a weld? It confuses me and there's only Part0 and Part1 in the weld's properties.
I am an owl. |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 09:39 AM |
actually no, this would be the working script
repeat wait() until game.Players.LocalPlayer
function PlayerAdded(player) function CharacterAdded(character) print("Player joined") end end game.Players.LocalPlayer.CharacterAdded:connect(CharacterAdded) game.Players.PlayerAdded:connect(PlayerAdded)
but it errors: Attempt to connect failed: Passed value is not a function |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 09:44 AM |
Hmm :o I never know what it means when it says the passed value isn't a function. Lol.
I am an owl. |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 09:59 AM |
Can anyone help me with one that can work? I don't think LocalPlayer works anymore, not sure. I tried the one the wiki gave me and it didn't work in a local script.
I am an owl. |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 10:20 AM |
Just to say
@Seat
Why are you you using PlayerAdded in a LocalScript?
Total Posts: 404 ---------- Not Found |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 10:30 AM |
| I don't think he recommended it to me, but i read the wiki, which said it works in local scripts and stuff. |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 10:31 AM |
Where did you see it works for LocalScripts?
"This event does not fire for LocalScripts"
Total Posts: 404 ---------- Not Found |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 10:46 AM |
It said on the wiki when I looked it up in the studio. here's what it says:
Value Type: Object Description: The Player that the LocalScript is running for. Example This gets the Player the LocalScript is running in. This must be in a LocalScript to work correctly throughout servers.
local player = game.Players.LocalPlayer print(player:GetFullName())
link: http://wiki.roblox.com/index.php?title=API:Class/Players/LocalPlayer
Wait am I allowed to post wiki links? :o
I am an owl. |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 10:47 AM |
Oh no, I was talking about PlayerAdded
Total Posts: 404 ---------- Not Found |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2015 10:51 AM |
Ohhh. I thought you were talking about the LocalPlayer or something. XD But anyways, I tried these scripts, but none worked. game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(characterAdded()) end) end) <--- yours looks a lot like the one I used, except mine is anonymous. The studio says that the "(characterAdded())" part is an unknown global 'characterAdded' or whatever. What does it mean? :o
I am an owl. |
|
|
| Report Abuse |
|
|
| |
|