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!
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)