Help with remote event kicking plr

**IT DOESNT WORK (IM TRYING TO KICK PLAYER IN TEXT GUI IF ITS STILL VISIBLE)
the method i was to use is below there are no errors.

this is my second remote event iv ever written so i dont know how to debug it**

  1. List item

local script

(inside textgui)script.Parent.Parent.Changed:Connect(function(plr)
        local ReplicatedStorage = game:GetService("ReplicatedStorage")
        local remoteEvent = ReplicatedStorage:WaitForChild("kick")

        remoteEvent:FireServer(plr)

        
    end
end)

script (Inside serverscriptservice)

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("kick")
local function onCreatePart(plr)
    plr:Kick("Dont Be AFK")

You need to β€œreceive” the remote event on the server using .OnServerEvent:Connect(function()

For example,

remoteEvent.OnServerEvent:Connect(onCreatePart)

where would i locate this? β€˜β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™β€™

Inside the server script where you kick the player.

-- Server script
local rep = game.ReplicatedStorage
local event = rep:WaitForChild("Event") -- Event goes here

function onCreatePart(plr)
    plr:Kick("Message") -- Message you want to send
end

event.OnServerEvent:Connect(onCreatePart)




-- Local script
script.Parent.Parent.Changed:Connect(function()
        local rep = game:GetService("ReplicatedStorage")
        local event = ReplicatedStorage:WaitForChild("Event") -- Event

        event:FireServer()

        
    end
end)

You cant fire β€œplr” in a local script. The player is already a local.

1 Like