On clicked increase speed

  1. Im trying to make it so when you click a button player walkspeed increases to X.
  2. Whenever I click the button, it doesn’t respond. No functions work which leads me to believe its the variables and not the Mouse:connect function.
  3. Here is the script:
    local player = game.Players.LocalPlayer
    local char = player.CharacterAdded:wait()
    local h = char.Humanoid

--Increase speed by X when clicked.
script.Parent.MouseButton1Click:Connect(function()
h.WalkSpeed = 99
print("Speed exploits have been fired!")
end)

Before you get mad no I’m not making exploits, I’m making an exploit testing plugin.

If you run the function(in a local script in a text button) nothing will happen and no print will be in the output. The thing is no bugs occur in my game and I’m getting the vars directly from roblox ed hub. Any help is thanked!

1 Like

Try replacing local char = player.CharacterAdded:wait()
with
local char = player.Character or player.CharacterAdded:Wait()

1 Like

Didn’t seem to work. Still doesn’t return Printed

Can you try putting a print(h.Name) before the function, to see if the humanoid is being registered?

I think the humanoid is returning as nil currently

Try using WaitForChild() on the humanoid variable


nothing is registering

It returns its not a valid member of rbx script service.

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local h = char:WaitForChild("Humanoid")
--Increase speed by X when clicked.
 
script.Parent.MouseButton1Click:Connect(function()
    print("Event fired")
    h.WalkSpeed = 99
    print("Speed exploits have been fired!")
end)

Try this?

1 Like

Ahah I now run at 99 speed. Thanks mate for your help!

1 Like

Np, also as a side note even though the Character may load when using CharacterAdded:Wait(), it may not be able to load the Humanoid in time as well so just to be sure use the WaitForChild() function so that it yields until the current object is found

Example:

local Part = workspace:WaitForChild("Part") --Will wait until a part is found, now we know it's there