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

Why is this script that is supposed to change player speed not working?

Asked by 8 years ago

The script is in a tool, and it is supposed to increase the player's speed when they equip it, and return their speed back to normal when they unequip it.

However, the script isn't working at all, and I don't know why. I did get output, however.

Can someone please help me?

Here's the script:

script.Parent.Equipped:connect(function()
script.Parent.Handle.CoilSound:Play()
if script.Parent.Parent:FindFirstChild("Humanoid") then
    script.Parent.Parent.Humanoid.WalkSpeed = 32
end
end)

script.Parent.Unequipped:connect(function()
script.Parent.Handle.CoilSound:Play()
if script.Parent.Parent:FindFirstChild("Humanoid") then
    script.Parent.Parent.Humanoid.WalkSpeed = 16
end
end)

Output: "Equipped is not a valid member of Model"

0
The output tells me that script.Parent = a mode, post the ancestry tree so we can answer better. User#5978 25 — 8y
0
This script seems to work fine for me. Are you sure you have a Handle inside the Tool? Since without the handle inside the tool the tool want work UserOnly20Characters 890 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

One thing to note, from what I have tested it will not work if there is no part in the Tool named Handle.

Here is the code for a LocalScript you can use, not sure why you're script won't work though.

Sorry I couldn't explain it any better.

wait(0.5) -- Prevent error's while searching for the player

local player = game.Players.LocalPlayer -- Easier way then repeating it alot of times

script.Parent.Equipped:connect(function() -- Equipped function
    script.Parent.Handle.CoilSound:Play() -- Play the sound
    if player.Character:FindFirstChild("Humanoid") then -- Search for the Humanoid
        player.Character.Humanoid.WalkSpeed = 32 -- Change the walkspeed
    end -- End the search
end) -- End the function

-- Won't explain below cause it is pretty much the same.

script.Parent.Unequipped:connect(function()
    --script.Parent.Handle.CoilSound:Play()
    if player.Character:FindFirstChild("Humanoid") then
        player.Character.Humanoid.WalkSpeed = 16
    end
end)
0
Thanks! CoolJohnnyboy 121 — 8y
Ad

Answer this question