I have been making a Roblox simulator and the sell has not been working. I have tried multiple scripts and people say they work but none of them have been working for me. There are no errors but the cash never changes. Here they are.
It has a remote event in ReplicatedStorage and a server script in a part. I have this in a different game and it is still working so I don't know what happened in the current one. Here is the script from the part. Now, this script is taken from the game its working in because I took it out of the one I'm making.
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
game.ReplicatedStorage.Sell:Fire(player)
end
end)
This is the script in a server script in server script service.
ReplicatedStorage.Sell.Event:Connect(function(player)
if player ~= nil then
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + player.leaderstats.Sticks.Value*2
player.leaderstats.Sticks.Value = 0
end
end)

2 comments
If you're saying that the script is taken from another game and it works for that game then it's either: a) something is placed incorrectly in the
explorer or b) the directory for where the script is looking (example game.Workspace) is incorrect.