Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Kill button and Kick button do not work?

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?

2 comments

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

0

^ To Add: Try instead local character = player.Character or player.CharacterAdded:Wait()

1 answer

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.