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

Can you help me fix my killing GUI? It is not working and I need advice.

Asked by
fardxD 9
4 years ago

So basically, I am making a GUI that kills people when you put their name in a box and press the "Kill Player" Button. This is the script I came up with.

local Person = game.StarterGui.KillGUI.PlayerNameHere.Text
script.Parent.MouseButton1Click:Connect(function()
        game.Workspace.Person:BreakJoints()
end)

So basically, I put a ScreenGUI and named it KillGUI. I then put a text box in there and named it "PlayerNameHere." The game is also FilteringEnabled, just in case that helps you out. Thanks!

1 answer

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

First Make A Remote Event In Replicated Storage And Call It KillPlayerEvent

Secondly Here Is The Code To Put In The Kill Player Button:

local event = game.ReplicatedStorage.KillPlayerEvent
local playertokill = script.Parent.Parent.PlayerNameHere

function killselectedplr()
event:FireServer(playertokill)
end

script.Parent.MouseButton1Down:Connect(killselectedplr)

Lastly Put A Script In ServerScriptService And Put This Code In It:

local event = game.ReplicatedStorage.KillPlayerEvent

event.OnServerEvent:Connect(function(player,killselectedplr)
if workspace:FindFirstChild(killselectedplr) ~= nil then
workspace:FindFirstChild(killselectedplr):FindFirstChild("Humanoid").Health = 0
end
end)

Hope This Helps If Not Feel Free To DM Me: Harry_TheKing1#2303

I Will Soon Upload A Video On YouTube On How To Do This :)

Ad

Answer this question