What do you want to achieve? I am trying to make a sell script for my simulator.
What is the issue? My script isn’t working even though it should.
What solutions have you tried so far? Originally I made my own script and it didn’t work so I asked a friend about it and they couldn’t find anything wrong, but they gave me their script. I inserted it in, changed some things to fit with my game, and it still doesn’t work.
Script
local ifsound = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if ifsound == false then
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Player.leaderstats.Claps.Value >= 1 then
ifsound = true
script.Audio:Play()
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
Player.leaderstats.Money.Value = Player.leaderstats.Money.Value + Player.leaderstats.Claps.Value
Player.leaderstats.Claps.Value = 0
print("TEST")
wait(1)
script.Audio:Stop()
wait(0.5)
ifsound = false
end
end
end
end)
alright my suspicions are true. By using a local script, you’re changing the stats of the player (number of claps) on the client (or the player’s computer basically), so the server doesn’t have access to that information. So to the server, your amount of claps is ALWAYS at 0. You need to use remote events to prevent this from happening. Its complicated, I’m sure you can find a video on it. (And no, just switching the script to a normal script will not work)