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

Why is OnClientEvent bringing out an error? [CLOSED]

Asked by 7 years ago
Edited 7 years ago

I couldn't figure out why this error occurs: 16:47:19.225 - OnCilentEvent is not a valid member of RemoteEvent

This function is listed on the Roblox Wiki and it doesn't work for me. I'm new to RemoteEvents. Am I doing a easy mistake?

-- Server Script
game.Players.PlayerAdded:connect(function(player)
    local event = Instance.new('RemoteEvent',player)
    local playerName = player.Name
    -- more stuff
    event.Name = 'Dead'
    event:FireCilent(playerName,1,"asmiundyuay",99999999999)
end)
-- Cilent Script
local event = game.Players.LocalPlayer:WaitForChild('Dead')
event.OnCilentEvent:connect(function(typeOfPower,Profile,XP)
    print(Profile,XP)
end)
0
You spelled Client wrong? Not sure if that was on purpose. Brinceous 85 — 7y

1 answer

Log in to vote
3
Answered by
Netflixy 126
7 years ago
Edited 7 years ago

You misspelled client, as you typed cilent. Also, you are attempting to fire this to a string, when it should be a Player instance.

Should work:

-- Server Script
game.Players.PlayerAdded:connect(function(player)
    local event = Instance.new('RemoteEvent',player)
    local playerName = player.Name
    -- more stuff
    event.Name = 'Dead'
    event:FireClient(player,1,"asmiundyuay",99999999999) --Here you tried to fire it to a string, should be an instance player. You also misspelled Client here.
end)
-- Cilent Script
local event = game.Players.LocalPlayer:WaitForChild('Dead')
event.OnClientEvent:connect(function(typeOfPower,Profile,XP) --here you spelled client incorrectly
    print(Profile,XP)
end)

0
Surprised I didn't see that, thanks! fighter169mobile 123 — 7y
Ad

Answer this question