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

How do I make a script that when a player enters a name, the other player gets killed?

Asked by 10 years ago

I need help with this for a gui.. Script:

function onClicked(click)
local plr = script.Parent.Parent.TextBox.Text
game.Players.plr.Character.Humanoid.Health = 0
end

script.Parent.MouseButton1Down:connect(onClicked)

Please try to answer!

1 answer

Log in to vote
0
Answered by
Discern 1007 Moderation Voter
10 years ago

You are actually very very close. The error is on line 3. plr is a string, not a player, so you define that by using []'s.

function onClicked(click)
local plr = script.Parent.Parent.TextBox.Text
game.Players[plr].Character.Humanoid.Health = 0 --NOTE There is NO period after "Players"
end

script.Parent.MouseButton1Down:connect(onClicked)

:)

0
Oh, thanks! ;) Operation_Meme 890 — 10y
0
Np :) Discern 1007 — 10y
Ad

Answer this question