Story
So, I making a parkour game, and I need help with a Gui, so i have made all of the parkour courses and everything, so i got an idea of like a trolling kind of gui which would troll another player, like killing them.
I need Help With
so i made a gui and i need help, like when a player puts another player’s name and hits the “kill” button,
i want to make it so that it should kill the player.
I tried to make it on my own but i wasnt able to.
Also I am not that good of a scripter.
Any Help Would be great for me.
The problem here is most likely that you tried to get the text of the textbox from the server, but it can only be seen from the client. So, you should be using remote events.
(local script)
local button = --kill button
local name = --textbox
local killevent = --the remote event
button.MouseButton1Down:Connect(function()
if string.len(name.Text) >= 3 and string.len(name.Text) <= 20 then
killevent:FireServer(name.Text)
end
end)
(server script)
local killevent = --remote event
killevent.OnServerEvent:Connect(function(plr, targetname)
local target = game.Players:FindFirstChild(targetname)
if target and target:IsA("Player") then
if target.Character and target.Character.Humanoid.Health > 0 then
target.Character.Humanoid.Health = 0
end
end
end)
you should probably put the local script within the GUI, the server script in ServerScriptService, and the RemoteEvent in ReplicatedStorage. Make sure to reference everything properly.