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

Why are my remote event arguments returning nil? [Answered]

Asked by 6 years ago
Edited 6 years ago

My game is FE so I need to use remote events and I want to pass arguments through them but when I reference them in my server scripts, they return nil?

--Local Script (inside a tool in Workspace)

tool = script.Parent
local guiuse = script.Parent.PowerGui:Clone()

local RepStorage = game:GetService('ReplicatedStorage')
local ToolEvents = RepStorage:WaitForChild("ToolEvents")
local Heavy = ToolEvents:WaitForChild("Heavy")
local Light = ToolEvents:WaitForChild("Light")

function heavy()
    Heavy:FireServer(script.Parent, guiuse)
end
function light()
    Light:FireServer(guiuse)
end

tool.Equipped:connect(heavy)
tool.Unequipped:connect(light)

--Server Script (inside ServerScriptService)

Heavy.OnServerEvent:connect(function(player, parent, guiuse)
    parent.Movement.Disabled = true
    guiuse.Parent=game.Players:GetPlayerFromCharacter(parent.Parent).PlayerGui
    parent.Movement.Disabled = false
end)

Light.OnServerEvent:connect(function(player, guiuse)
    guiuse.Parent = nil 
end)

1 answer

Log in to vote
0
Answered by 6 years ago

Almost every time I post a question, I figure it out 1 hour later. Anyways, I read more into this wiki page and it said that by default, player is passed through, which I totally neglected and added player anyway. After I removed the player variable because I didn't need it, it worked.

Ad

Answer this question