Code:
coin = script.Parent local player = game:GetService("Players") local Stats = Instance.new("IntValue") Stats.Parent = player Stats.Name = "leaderstats" -- Variables game.Players.PlayerAdded:Connect(function() coin.Touched:Connect(function() player.leaderstats.Value = player.leaderstats.Value + 1 wait(2) coin.Transparency = 1 end) end) -- Function print("Worked")
It printed 0 errors, please help!
—This should be in serverscriptservice
game.players.playeradded:Connect(function(player)
local leaderstats = Instance.new(“Folder”) leaderstats.Name = “leaderstats” leaderstats.Parent = player local Coins = Instance.new(“IntValue”) Coins.Name = “Coins” Coins.Parent = leaderstats
end)
—This should be in the coin
script.Parent.Touched:Connect(function(hit) local player = game.Players.FindFirstChild(hit.Parent.Name) player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 10 -- Amount you get script.Parent.Parent = game.ServerStorage wait(5) -- how much seconds to wait after collecting again script.Parent.Parent = game.Workspace end)
this should be inside the server script service
game.Players.Playeradded:Connect(function(player) local leaderstats = Instance.new(“Folder”) leaderstats.Name = “leaderstats” leaderstats.Parent = player local Coins = Instance.new(“IntValue”) Coins.Name = “Coins” Coins.Parent = leaderstats end)
this should be in the coin
Script.parent.Touched:Connect(function(hit) if game.Players:GetPlayerfromCharacter (hit.Parent) then local TouchedPlayer = game.Players:GetPlayerfromCharacter (hit.Parent) local CoinValue = TouchedPlayer.leaderstats.Coins.Value CoinValue = CoinValue + 1 Script.Parent:Destroy end end)
i didn't test this so don't blame me if it doesn't work