Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Shop system values acting weird?

Asked by 5 years ago

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?

0
Can you provide the errors? User#19524 175 — 5y
0
No errors appear in the output for some reason. The only errors that appear are for different scripts unrelated to the items, I think. yoshikins101 11 — 5y
0
Oh yeah, I forgot to include the fact that both items use the same RemoteEvent. Should I make a second RemoteEvent for the second item to use? yoshikins101 11 — 5y

Answer this question