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)
Hello, you mistakened bindable event calls for remote event ones :D!
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) game.ReplicatedStorage.Sell:FireServer() end end)
And thats server one:
ReplicatedStorage.Sell.OnServerEvent: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)
This problem has been solved from Stack Overflow. If you want to see how it was solved just read through the stuff here. https://stackoverflow.com/questions/72065230/how-do-i-make-a-sell-script-roblox/72070998#72070998