Hi, I am making a game and I want to make a currency system. I have created the handler in a normal script in the ServerScriptService but I have no idea how to make it so that when a player touched a part (coin in my case) it adds one value to the players leaderstats.
so this is simple enough, you just need to add a value to the leaderstat. Hope this helps!
--put this code in the coin amount = 1 --how much you get for touching it function onTouched(part) local humanoid = part.Parent:FindFirstChild("Humanoid") if (humanoid~=nil) then local touch = game.Players:FindFirstChild(humanoid.Parent.Name) local leaderstats = touch:FindFirstChild("leaderstats") local points = leaderstats:FindFirstChild("Points") -- change "Points" with you own currency points.Value = points.Value + amount end script.Parent:Destroy() -- optional, I added this because I think you'll want to destroy the coin after touching it. end script.Parent.Touched:Connect(onTouched)