So I'm working on a lab game with research points leaderstats. If I'm making a script where a leaderstat needs to be decreased, it decreases not with 20 like I said in the script, but with way more. For example. If I buy a product requires 20 points, I give the player the product, and points are gone, but not the amount of points I gave the script. There's also a new bool instance thing but that works fine.
Here's the script:
script.Parent.MouseButton1Click:Connect(function() local plr = script.Parent.Parent.Parent.Parent.Parent plr.leaderstats.Research.Value = plr.leaderstats.Research.Value - 20 local bool = Instance.new("BoolValue",plr) bool.Value = true bool.Name = "HasTestSubject" end)
It's in a server script. I hope somebody knows what's wrong.
Try adding a "debounce". This will prevent an event from firing lots of times instead of one.
local deb = false script.Parent.MouseButton1Click:Connect(function() if deb == false then deb = true local plr = script.Parent.Parent.Parent.Parent.Parent plr.leaderstats.Research.Value = plr.leaderstats.Research.Value - 20 local bool = Instance.new(“BoolValue”,plr) bool.Value = true bool.Name = “HasTestSubject” wait(3) deb = false end)
Neither a debounce or a checker if the player already owns it work. Screenshot of the script: https://imgur.com/a/y3h8I0C Video of what the script does: https://youtu.be/3HAzXDoGfFs (In the video look at the leaderstats)