Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Why won't my remote event be detected on fired!?

Asked by 6 months ago
Edited 6 months ago

So I have 2 scripts a script and local so what I tried to make is that in the server, it will change a value. In the client, I want it to change a color of a button when pressed. The server script doesn't change the values . The local script function doesn't run. Why?

Note: Just realized I typed formRGB() I changed it so just ignore it.

Script

script.Parent.MouseButton1Click:Connect(function()
    local plr = script.Parent.Parent.Parent.Parent
    local event = game.ReplicatedStorage.DuelColor
    if plr.InDuel.Value == true then
        plr.InDuel.Value = false
        event:FireClient(plr,1,script.Parent)
    end
    if plr.InDuel.Value == false then
        plr.InDuel.Value = true
        event:FireClient(plr,2,script.Parent)
    end
end)

Local Script

local event = game.ReplicatedStorage.DuelColor
event.OnClientEvent:Connect(function(number,gui)
    print("Yay!")
    if number == 1 then
        gui.BackgroundColor3 = Color3.formRGB(255,0,0)
    end
    if number == 2 then
        gui.BackgroundColor3 = Color3.formRGB(0,255,0)
    end
end)
Edit: fixed font of the text, it was too big.
0
MouseButton1Click is an event of a GuiButton. This should be used in a local script so there isn't a need for a RemoteEvent here. xPolarium 1358 — 6mo
0
maybe you mean to use ClickDetector.MouseClick instead of MouseButton1Click? Vulkarin 580 — 6mo
0
i have a question too, how did you make that text smaller? xd starmaq 834 — 6mo

Answer this question