Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

2 comments

1

You forgot to use :Connect so game.ReplicatedStorage.msg.OnServerEvent:Connect(f1)

0

ahhhhhhhhhhhh ok!!! thanks. 

1 answer

✓ Accepted answer
function f1(text,player)
	game.Players:FindFirstChild(player).Character.Head.Msg.Image.Texter.Text = text
	end
	 
	game.ReplicatedStorage.msg.OnServerEvent:Connect(f1)

1 comment

0

-1 for not having an explanation

This discussion is preserved as it was. New answers, comments, and votes are closed.