so i’m working on a project. the player has a vacuum and when it is equipped, they are then able to step over coins, which adds to the “Coins” Value in their leaderstats. the leaderbord itself works, but the coin collection system doesn’t. below are the scripts.
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder",player)
leaderstats.Name = "leaderstats"
local Coins = Instance.new("IntValue",leaderstats)
Coins.Name = "Coins"
end)
here is my tool script: ( there is a remote event in the script).
this script is a local script btw.
script.Parent.Equipped:Connect(function()
script.Parent.RemoteEvent:FireServer()
end)
and here is a server script, which is supposed to make it so when the remote event is fired, they can walk over the coin and it adds to the leaderstats.
game.StarterPack.Vacuum.RemoteEvent.OnServerEvent:Connect(function(player)
script.Parent.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent)then
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1
end
end)
end)
thanks for reading.