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

Why isnt this remote event working?

Asked by 6 years ago

i have a server script sending a clientevent to the local player. in play mode everything works perfectly. but in multiplayer it comes up with this error

attempt to index global 'button' (a nil value)

Before you say that "Nil means that it doesnt exist" it does exist, like i said it works in play mode so if it is working in play mode, it means the variable does exist, doesnt it?

Heres the server script

function clicked(player, button)
local Button = button 
game.ReplicatedStorage.Remotes.PlayerCrateClick:FireClient(player,Button)
end
game.ReplicatedStorage.Remotes.CrateClick.OnServerEvent:Connect(clicked)

Heres the function in a local script

function clicked(Button)
button = Button
button.Parent.BackgroundColor3 = Color3.new(115/255,115/255,115/255)
openbutton.Visible = true 
openbutton:TweenSize(UDim2.new(0, 200, 0, 70), "Out", "Bounce", 1)
end
0
when did you fire the server in the local script? hiimgoodpack 2009 — 6y
0
why don't you just do function clicked(button) instead of function clicked(Button) then button = Button????? and use Color3.fromRGB abnotaddable 920 — 6y
0
Im not talking about color3s, okay ignore that... @abnotaddable i did that but im still getting the same error.. shootthegame 14 — 6y
0
@abnotaddable i put the button = Button thing because i need to use the same variable around the whole script... shootthegame 14 — 6y

Answer this question