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

attempt to call field 'OnServerEvent' (a userdata value)?

Asked by
ksony 54
5 years ago

attempt to call field 'OnServerEvent' (a userdata value) Hi, I has two scripts, One Server Script, Other Local Script, they contact by remote event. The error is in the server script

Local Script :



local player = game.Players.LocalPlayer script.Parent.MouseButton1Click:Connect(function() game.ReplicatedStorage.msg:FireServer(script.Parent.Parent.TextBox.Text, game.Players.LocalPlayer.Name) end) script.Parent.Parent.TextBox.FocusLost:Connect(function(enterPressed) game.ReplicatedStorage.msg:FireServer(script.Parent.Parent.TextBox.Text, game.Players.LocalPlayer.Name) end)

Server Script :



function f1(text,player) game.Players:FindFirstChild(player).Character.Head.Msg.Image.Texter.Text = text end game.ReplicatedStorage.msg.OnServerEvent(f1)
1
You forgot to use :Connect so game.ReplicatedStorage.msg.OnServerEvent:Connect(f1) User#5423 17 — 5y
0
ahhhhhhhhhhhh ok!!! thanks.  ksony 54 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
function f1(text,player)
    game.Players:FindFirstChild(player).Character.Head.Msg.Image.Texter.Text = text
    end

    game.ReplicatedStorage.msg.OnServerEvent:Connect(f1)
0
-1 for not having an explanation User#24403 69 — 5y
Ad

Answer this question