This gives me 1 point when it is touched. When it is touched, how would I make it removed?
amnt = 1 function onTouched(part) local h = part.Parent: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 script.Parent.Touched:connect(onTouched) script.Parent.Touched:Remove()
You simply need to use the :Destroy()
method. It removes the part exactly how you want.
We'll use it like this:
game.Workspace.Part:Destroy() --Destroys the part
Now let's apply it to your script:
amnt = 1 function onTouched(part) local h = part.Parent: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 script.Parent:Destroy() --Added it in right here to destroy part end end end end end script.Parent.Touched:connect(onTouched)
It should work now.
Anyways, hope this helped. If you have any further problems/questions, please leave a comment below :P