So im making a gui where when you type a players name, It kills them, simple, but i dont know how to do this. How would i do this?
I've tried
script.Parent.MouseButton1Click:Connect(function() script.Parent.vic.Value = script.Parent.Text end)
how would i fix this?
Thanks,
You’d need quite a lot more then that. To kill an avatar, you’d have to put that weight on the Server, as doing so locally won’t replicate to the victim nor the rest of the Clients; they will only die on your device. To solve this issue, we will have to perform the reset within a ServerScript
bound by a RemoteEvent
to a LocalScript
.
The LocalScript is still required to handle the input.
Begin by placing a ServerScript within ServerScriptService
and a RemoteEvent within ReplicatedStorage
--// ServerScript local ReplicatedStorage = game:GetService("ReplicatedStorage”) local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent") local Players = game:GetService("Players") local function ResetGivenPlayer(_,TargetPlayer) if not (TargetPlayer) then return end local Player = Players:FindFirstChild(TargetPlayer) if (Player and Player.Character) then local Humanoid = Player.Character:FindFirstChildOfClass("Humanoid") if (Humanoid) then Humanoid:TakeDamage(Humanoid.Health) end end end RemoteEvent.OnServerEvent:Connect(ResetGivenPlayer) --// LocalScript local ReplicatedStorage = game:GetService("ReplicatedStorage”) local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent") local TextBox = script.Parent -- Should be a TextBox --// MouseButton1Click can only be called on a GuiButton local function CallResetOnPlayer(EnterPressed) if not (EnterPressed) return end RemoteEvent:FireServer(TextBox.Text) end TextBox.FocusLost:Connect(CallResetOnPlayer) --// is conditioned to fire when we press return after typing out target