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

It won't kick the player?

Asked by 5 years ago

Local script:

local RepStorage = game:GetService("ReplicatedStorage")
local Remote = RepStorage:WaitForChild("TestKickEvent")

script.Parent.MouseButton1Click:Connect(function()
    wait(0.1)
    Remote:FireServer(script.Parent.Parent.EnterNameForKick.Text)
end)

Server Script:

local RepStorage = game:GetService("ReplicatedStorage")
local Remote = RepStorage:WaitForChild("TestKickEvent")

Remote.OnServerEvent:Connect(function(player, name)
    name:Kick("test")
end)

Error: ServerScriptService.Script:5: attempt to call method 'Kick' (a nil value)

1 answer

Log in to vote
1
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
5 years ago

Strings don't have a method called Kick. You can find a player associated with the string sent over the remote:

Remote.OnServerEvent:Connect(function(player, name)
    local pl = game.Players:FindFirstChild(name)
    if pl then
        pl:Kick('test haha')
    end
end)
0
It doesnt kick the player though still retrobricks 162 — 5y
0
Then you aren't giving the RemoteEvent the right name? It's case sensitive Shawnyg 4330 — 5y
Ad

Answer this question