I'm wondering if this is set up correctly? The functionality of this script would be when a user pushes a button, they're kicked from the server. I know you can do this easily another way, I just need help with remote functions.
--In LocalScript local player = game.Players.LocalPlayer.Name script.Parent.MouseButton1Down:connect(function() -- Lets say the scripts in a textbutton game.Workspace.RemoteFunction:InvokeServer(player) end) --In ServerScript local rf = Instance.new("RemoteFunction") rf.Parent = game.Workspace rf.Name = "RemoteFunction" function rf.OnServerInvoke(player) game.Players[player]:Kick("You kicked yourself") end
Okay, a few things wrong here.
1: You cannot call "OnServerInvoke" from a client. That defeats the purpose of it having server-to-client communication.
2: You don't need a variable for the client.
3: The first argument of InvokeServer is the client by default, so we don't need to return any values.
Try this:
-- This is inside a server script local rf = Instance.new("RemoteFunction",workspace) -- The function should be created in a server script environment. function rf.OnServerInvoke(client) client:Kick("You've been kicked") end -- This is inside a local script repeat wait() until workspace:FindFirstChild("RemoteFunction") -- just incase it hasn't loaded yet local rf = workspace.RemoteFunction script.Parent.MouseButton1Down:connect(function() rf:InvokeServer() end -- You will now find yourself being kicked when you press the GUI button.