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

FireClient passing through a value but OnClientEvent receiving a nil? [solved]

Asked by 4 years ago
Edited by User#5423 4 years ago

This question has been solved by the original poster.

So I send a FireClient() with one argument. Code (server script):

local amountRepaired = script.Parent.Repaired.Value
rpl.UpdateRepair:FireClient(Player, amountRepaired)

I already checked and amountRepaired is not nil. But when this is received through OnClientEvent (local script):

local function onUpdateRepair(amount)
    player.PlayerGui.gui.RepairFrame.Visible = true
    player.PlayerGui.gui.RepairingText.Visible = true
    player.PlayerGui.gui.RepairFrame.Bar.Size = UDim2.new(1/(100/amount), 0, 1, 0)
end

replicatedStorage.HideRepair.OnClientEvent:Connect(onUpdateRepair)

It gives me the error that it can't divide by nil and also when I print amount out it just prints nil. I've been trying to figure this out for a while so if someone can help me with this it would be greatly appreciated.

0
oh my god can you please format your code TiredMelon 405 — 4y
0
Im sorry i just realized and fixed it. I used the wrong code button KingStared 3 — 4y
1
those are two different events, one is UpdateRepair and one is HideRepair Fifkee 2017 — 4y
0
Oh I have another remote event that is called HideRepair and I forgot to change the name. Stupid mistake. Thank you KingStared 3 — 4y
View all comments (2 more)
0
Idk if I'm supposed to mark it as solved since I can't find somewhere for that but it is. KingStared 3 — 4y
0
add [solved] to mark as self solved User#5423 17 — 4y

Answer this question