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

Why won't a remote event inside a function that's called work?

Asked by 5 years ago

i get this error:13:18:03.913 - Trying to call method on object of type: RemoteEvent with incorrect arguments.

when i do this:

Server script

textlabelchanger = game.ReplicatedStorage:WaitForChild("TextLabelChanger") -- a remote event
local function textlabelchange (player)
    textlabelchanger:FireClient(player)
end

textlabelchange(player)

Local script

playergui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
textlabelchanger = game.ReplicatedStorage:WaitForChild("TextLabelChanger")
textlabel = playergui.ScreenGui:WaitForChild("TextLabel")

local function textlabelchange()
    textlabel.BackgroundTransparency = 0.5
    textlabel.BorderSizePixel = 2
end

textlabelchanger.OnClientEvent:Connect(textlabelchange)
0
'player' isn't defined, so you're firing a remote event to nil. Additionally you should never use global variables. User#19524 175 — 5y
0
Alright i added local player = game:GetService("Players") on line 2 of server script but the same error occurs GamingOverlord756 48 — 5y

Answer this question