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

Why wont anything happen with this leaderstat?

I tried to make a script where when they touch a part, the number of clicks they had turned into the number of coins they have. Can someone tell me why this script does not work?

local Part = script.Parent

local function hit()
	
	game.Players.LocalPlayer.leaderstats.Coins.Value = game.Players.LocalPlayer.leaderstats.Clicks.Value
	
end

Part.Touched:Connect(hit)

Thanks!

1 answer

Because you're doing it on the client (LocalScript), it's ideal that the leaderstats are handled by the server (Script).

local Part = script.Parent

local function onHit(Hit)
	local Players = game:GetService('Players')
	local Player = Players:GetPlayerFromCharacter(Hit.Parent)
	if Player then
		Player.leaderstats.Coins.Value = Player.leaderstats.Clicks.Value
	end
end

Part.Touched:Connect(onHit)

3 comments

0

Nothing happened no error either

0

Nothing happened no error either

0

He means that this code should be a normal script inside the part.

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