In line 4, the location of the players username (hit.PlayerName.Value)
The PlayerName cannot be accessed here, hit is what has hit the part.
To find the username you would have to do: PlayerName = hit.Name (Hit would be the players character model, the name of the model would be the players name.)
game.Players.PlayerName.Value = game.Players.PlayerName.Value + 100
This accesses the value that i am assuming is in the Players folder. Since PlayerName is the name of the Player, the code is basically telling itself (If i was the player that hit the part)
game.Players.Kulh.Value = game.Players.Kulh.Value + 100
Example:
script.Parent.Touched:connect(function(hit)
print("he")
if hit:FindFirstChild("Humanoid") then
local plv=game.Workspace.Jobs.Coffee.PlayersInArea:FindFirstChild(hit.Name)
game.Players.plv.Value = game.Players.plv.Value + 100
end
end)
7 comments
I've tested it in a server, and it seems to work just fine. Perhaps you have it as a LocalScript instead of a Server side script?
Doesn't work but the item has a mesh, does that affect anything?
Oh yeah, it doesn't even print it when a player touches it...
Is the script a LocalScript or just a Script? Where is the script located?
You gotta check if it's a player or not; if a object that isn't a character/ player, it will not work.
Just read the rest; did you check for errors at all? My guess is that the script's parent may not have loaded, but if this's only a snippet of the actual code, we'll need to know in order to help you.
Look. The problem isn't that stuff under the print command. The problem is that it won't print "he" at all. Also apparently it works now.