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

Why is event parameter stacking?

Asked by 2 years ago
Edited 2 years ago

this is a button that sends the parameter (there's like 10 of it with different parameter):

btn.MouseButton1Click:Connect(function()
    if db == false then
        db = true
        confirm.Visible = true
        wait()
        tween1:Play()
        tween2:Play()
        event:FireServer()
        guievent:FireServer(prodName, price)
    end
end)

this is the event handler inside a script:

event.OnServerEvent:Connect(function(plr, val, val2)
    guievent:FireClient(plr, val, val2)
end)

this is a localscript:

rs.GuiEvent.OnClientEvent:Connect(function(name, price)
    confirm.Visible = true
    btn.MouseButton1Click:Connect(function()
        rs.Editor:FireServer("SetHair", name)
        rs.Editor:FireServer("Buy", price)
        rs.SmallGui:FireServer(name)
        print(name, price)
        tween1:Play()
        tween2:Play()
        wait(.7)
        confirm.Visible = false
    end)
end)

This thing works well on the first try, but if you try different button after the first one the parameter stacks and it will return the old and new value. I tried using a table so I can remove the old ones and add the new one but I can't make it work.

0
You're subscribing to an event within another; each time RemoteEvent.OnClientEvent fires, you set up **another** GuiButton.MouseButton1Click listener. Each separate listener will perform the same action, but send whatever information was provided at its creation. Ziffixture 6913 — 2y
0
Avoid doing this, obviously. A rework of your system is in order. Ziffixture 6913 — 2y

Answer this question