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

whenever i click with the tool on the screen, the points in the leaderboard dont add up?

game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new ("Folder",player) leaderstats.Name = "leaderstats" local points = Instance.new ("IntValue",leaderstats) points.Name = "points"

end)

game.StarterPack.swordtool:Activate(function(hit) local playerpoints = game.leaderstats.points if hit then playerpoints.Value = playerpoints.Value + 1 end end)

1 answer

Tools in StarterPack are simply there to be (automatically) cloned into each player's backpack.

Also, you are inconsistent with where the leaderstats folder is stored. In the first section, you parent the folder to the player. In the second section, you are getting the leaderstats folder from game (you were right in the first section, it should be parented to the player).

The best way to add points to the player's leaderstats would be to use a RemoteEvent.

To do this, you would fire an event from the client (local script) to the server and request points to be added to the player's leaderboard stat.

Server-side:

local pointsEvent = -- Location of remote event

event.OnServerEvent:Connect(function(player)
	player.leaderstats.points.Value += 1
end)

Client-side:

local tool = script.Parent
local pointsEvent = -- Location of remote event
tool.Activated:Connect(function()
	event:FireServer()
end)

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