I'm making a shop and one of the items is a speed boost that lasts for one life. Once you click to spawn in, the script checks if the "speedpower" boolValue is true or false. If it is true, it gives you high speed and changes the value to false. The shop will not let you buy the speedpower if you already have it. However, if you die and no longer have the boolValue set to true, the script will still not let you buy it and reads that the value is True, even though it is false. Here is the Script
game.ReplicatedStorage.RemoteEvents.SpeedUpEvent.OnServerEvent:Connect(function(player) local money = player.leaderstats.Money local speedpower = player.powerstats.speedpower if money.Value >= 5 then print("Not Broke") if speedpower.Value == false then money.Value = money.Value - 5 speedpower.Value = true else print("Already Active") end else print("Broke") end end)
This is the other function, which fires when a menu button is clicked. It is in a local script, would this be the problem?
if powerstats:WaitForChild("speedpower").Value == true then player.Character.Humanoid.WalkSpeed = 30 powerstats:WaitForChild("speedpower").Value = false else player.Character.Humanoid.WalkSpeed = 16 end
If you're changing the BoolValue on the client and reading it from the Server, you're going to encounter issues with Filtering Enabled
(you can read up more about it in this scriptinghelpers post)
basically, you can't use line 3 in your code
-- line three powerstats:WaitForChild("speedpower").Value = false
.. because you are changing the BoolValue locally, which will not be replicated by the server
what you need to do instead is you can either:
hope this helps :)