Okay! I've been asking for help a lot around here (i apologize greatly- im not the best scripter ;w;) but I have on more problem.
In my game, I have buyable items. When someone buys an item, that item's value changes from 0 to 2. Whenever the player joins the game, the game checks if that item's value is 2. If it's 0, that means they haven't bought it yet. If it's 2, that means they bought it already, and it will not prompt them to buy it anymore.
I have two items that do this. I was struggling with them earlier, but someone helped me fix them. But now another weird glitch is happening.
If I buy the first item, both the first item AND the second item's values turn to 2, even though its only supposed to change the first item- the same thing happens when I buy the second item.
Does anyone know why this is occuring? I'll include the scripts just incase.
Here are the scripts for the first item below (the second item's scripts are identical, just changed to match the second item's name.)
(located in a textbutton. it is a local script)
script.parent.MouseButton1Down:Connect(function() game.ReplicatedStorage.RemoteEvent:FireServer(150) end) script.Parent.MouseButton1Down:connect(function() local player = game.Players.LocalPlayer if player.Stats.Pawprints.Value >= 150 then script.parent.Active = false script.parent.Visible = false end end)
(located in the same text button. also a local script)
local player = game.Players.LocalPlayer if player.Item.Itemnumber.Value == 2 then script.parent.Active = false script.parent.Visible = false end
(located in ServerScriptService. It is a server script)
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, value) if player.Stats.Pawprints.Value >= 150 then player.Stats.Pawprints.Value = player.Stats.Pawprints.Value- 150 player.Item.Itemnumber.Value = 2 end end)
NOTE: "pawprints" has nothing to do with the problem- that's just the ingame points. ALSO NOTE: The second buyable item has identical scripts to the above scripts, except their names are changed. That is the only difference.
Why does both the first item and the second item's values change to 2 when only one is supposed to?