Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help i need to know how to get the player name pls help?

Asked by 6 years ago

game.ReplicatedStorage.JumpPower.OnServerEvent:connect(function(plr) game.ServerStorage:FindFirstChild(plr.Name).Jump.Value = game.ServerStorage:FindFirstChild(plr.Name).Jump.Value + 1 end)

idk what the problem is becus the plr.Name works in my data script but not in this script pls help?

0
whats the code for your script that calls the JumpPower event? OMG_Gaming404 73 — 6y
0
just use it in a local script and change plr.Name to game.Players.LocalPlayer.Name TheSkyofIndia 150 — 6y

1 answer

Log in to vote
2
Answered by
Avigant 2374 Moderation Voter Community Moderator
6 years ago

You're using Instance:FindFirstChild() improperly. It will return nil if the object with the name can't be found.

So if you do this:

game.Workspace:FindFirstChild("Part").Name = "Hi"

Your code will error, because you are attempting to access nil.Name.

Furthermore, you should not have a RemoteEvent that is able to increase a value that the client can just request. Because exploiters can fire remotes with any arguments they want at any time, other than the implicit player argument you can trust, you should not trust the client!

As for why your code isn't working at all, you haven't provided enough context to the situation. It could be that there's no object in game.ServerStorage with the player's name in it when the remote is fired.

Ad

Answer this question