**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**
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")
-- 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.