so what this script does is find a tool called "Tape" and when it collides with the part, it adds 1 to the "Points" value in the leaderstats. however, despite NO ERRORS IN OUTPUT, AND WITH EVERYTHING SPELLED CORRECTLY, the script dosent work, please help!
script.Parent.Touched:connect(function(p) if p.Parent.Name == "Tape" then amnt = 2 local h = game.Workspace:findFirstChild("Humanoid") if (h~=nil) then local thisplr = game.Players:findFirstChild(h.Parent.Name) if (thisplr~=nil) then local stats = thisplr:findFirstChild("leaderstats") if (stats~=nil) then local score = stats:findFirstChild("Points") if (score~=nil) then score.Value = score.Value + amnt end end end end end)
this script is located inside workspace inside a model inside a part, so if you wanted to go to workspace, It would be script.Parent.Parent.Parent
This answer was modified for Adenandpuppy based on information not given in the post.
Your issue is you do not know how to find "Humanoid", or more specifically, the player that must be rewarded for placing tape in contact of your touching part. Here are two ways I suggest going about fixing your issue:
You stated the player is using a tool that drags "Tape" around, this means you should be able to tag "Tape" with an identifier that your touching part can use for rewarding. I suggest putting in a StringValue
with a value of the players name, using the grabbing tool to find the player. Using this, you would remove your humanoid check in your code and find the player through game.Players:FindFirstChild(StringValue.Value)
I would guess that the sort of game you make would have some based owned by the player where they are moving "Tape" onto some collector? If this is true, you could have an owner value in reach of the touching part to reward that owner every time "Tape" touches it.
I am sorry I cannot offer any more information or a more precise solution, but given the information provided, this is all I can do!