MY reset script isnt working why?

  1. i want ppl to be able to reset themselves through a gui

  2. when i click on it it doesnt activate

  3. i tried looking for stuff but didnt get it

function onActivated()
script.Parent.Parent.Parent.Parent.Character.Humanoid.Health = 0
end

script.Parent.Activated:connect(onActivated)```

anyone? plssss anyone? pls anyone

@uhley360
pls? are u there uhley

do you have any errors in output and is this script local script or server sided script

Try this

local plr = game.Players.LocalPlayer

local char = plr.Character or plr.CharacterAdded:Wait()

script.Parent.Activated:Connect(function()

if char and char.Humanoid then

char:FindFirstChild("Humanoid").Health = 0

end

end)

Try using MouseButton1Clic instead of Activated.

All it would’ve took is a simple youtube search, I found so many tutorials on this just by looking it up.

This works perfect for me

Have a good day :smiley:

is it for local script???

yes local script in your gui

charss

Just change script.Parent.Activated:connect(onActivated) to script.Parent.MouseButton1Click:connect(onActivated) and it should work.

Activated is for Mobile and pc thats not the problem

it doesnt work it says attempt to nil with character

That’s normal. You cannot use local char = plr.Character or plr.CharacterAdded:Wait(), you’ll have to use a function instead.


This screenshot is from DevHub of Roblox

If you don’t know what the script is doing, don’t copy and paste it.

Bro im using that method for character already long time it and works perfect for me please dont say things which you dont know

Edit: and im not “copy pasting” just showing that its method

it works i didnt do local script it works perfeclty

ye it should work cuz it was working perfectly for me

and is there any board of donation for mobile too