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

Kill button and Kick button do not work?

Asked by 6 years ago
local player = game.Players.LocalPlayer
player.CharacterAdded:Wait()
local character = player.Character
script.Parent.MouseButton1Click:Connect(function()
    local humanoid = character:FindFirstChildOfClass("Humanoid")
    if humanoid then
        humanoid.Health = 0
    end
end)

when i click it, it does not kill me

script.parent.MouseButton1Click:connect(function()
    game.Players.LocalPlayer:Kick("Removed from server!")
end)

and when i click this one it does not kick me

help?

0
`Kick` can only be used by a server script, and as for the first code, I believe it'd be waiting until the player respawns before execute that code. XP TheeDeathCaster 2368 — 6y
0
^ To Add: Try instead `local character = player.Character or player.CharacterAdded:Wait()` TheeDeathCaster 2368 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

You don't need lines 1-3 aswell as 5 in the first script, this is delaying the script. It should look like this:

function clicked(playerWhoClicked)
    playerWhoClicked.Character.Humanoid.Health = 0
end

script.Parent.MouseClick:connect(clicked)

Make sure that this script is not a LocalScript. ^ I'm not sure if I could help with the second script, sorry. Have fun scripting!

Ad

Answer this question