Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why doesn't it give the player a point when they touch the part?

Here is my script:~~~~~~~~~~~~~~~~~ player = game.Players.LocalPlayer

script.Parent.Touched:Connect(function(hit)

if player.hit then
	
	player.leaderstats.points.Value = points.Value + 1
end

end)




And then my LeaderBoard script~~~~~~~~~~~~~~~~~
 game.Players.PlayerAdded:Connect(function(player)
	

stats = Instance.new("IntValue",player)
stats.Name = "leaderstats"

points = Instance.new("IntValue",stats)
points.Name = "Points"



end)

1 answer

✓ Accepted answer

Localscript's do not work when parented to the workspace or a part that is inside the workspace instead use a server script not a local script and place this code inside it and parent it to the part

function Touch (hit)
	if hit.Parent:FindFirstChild('Humanoid') then
		local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
		local leaderstats = Player:WaitForChild('leaderstats')
		local Points = leaderstats:WaitForChild('Points')
		Points.Value = Points.Value + 1
	end
end

script.Parent.Touched:Connect(Touch)

4 comments

0

I would recommend using remote events for this, to prevent hackers.(Depending on what your doing)

0

Your completely wrong bad suggestion

0

that was rude ;(

0

But its true

This discussion is preserved as it was. New answers, comments, and votes are closed.