What do you want to achieve? I want to be able to go 2.1 speed whenever I walk with the tool but to be disabled whenever I click again or I unequip the tool
EDIT: I want to also make it so when I double tap w it unequips the tool
What is the issue? Whenever I walk it makes me the regular walk speed and not the 2.1 walk speed
EDIT: I don’t know how to script the double-tap w to unequip
What solutions have you tried so far? I’ve looked for solutions but nothing has helped!
EDIT: I cant find anything related to it too!
enabled = false
local Tool = script.Parent;
local dancer = nil
local player = game.Players.LocalPlayer
function onActivated()
--This will check if it is enabled and then either start dancing or stop dancing
if enabled == false then
local humanoid = Tool.Parent:FindFirstChild("Humanoid")
local torso = Tool.Parent:FindFirstChild("Torso")
dancer = humanoid:LoadAnimation(Tool.dance)
Tool.DanceObject.Value = dancer
dancer:Play()
Tool.dancepart.Position = player.Character.Head.Position
Tool.dancepart.SongLoop:Play()
enabled = true
speed = player.Character.Humanoid.WalkSpeed
player.Character.Humanoid.WalkSpeed = 2.1
repeat
wait(100)
Tool.dancepart.Position = player.Character.Head.Position
until enabled == false
else
dancer:Stop()
dancer:remove()
Tool.dancepart.SongLoop:Stop()
enabled = false
player.Character.Humanoid.WalkSpeed = speed
end
end
function onUnequipped()
dancer:Stop()
dancer:remove()
Tool.dancepart.SongLoop:Stop()
enabled = false
player.Character.Humanoid.WalkSpeed = speed
end
Tool.Activated:connect(onActivated)
Tool.Unequipped:connect(onUnequipped)
whenever I walk whilst dancing I walk at the regular walk speed and not 2.1 walk speed
You never declared speed as a variable here. Add it as a variable before the function
enabled = false
local Tool = script.Parent;
local dancer = nil
local player = game.Players.LocalPlayer
local speed = nil --declare speed
function onActivated()
--This will check if it is enabled and then either start dancing or stop dancing
if enabled == false then
local humanoid = Tool.Parent:FindFirstChild("Humanoid")
local torso = Tool.Parent:FindFirstChild("Torso")
dancer = humanoid:LoadAnimation(Tool.dance)
Tool.DanceObject.Value = dancer
dancer:Play()
Tool.dancepart.Position = player.Character.Head.Position
Tool.dancepart.SongLoop:Play()
enabled = true
speed = player.Character.Humanoid.WalkSpeed
player.Character.Humanoid.WalkSpeed = 2.1
repeat
wait(100)
Tool.dancepart.Position = player.Character.Head.Position
until enabled == false
else
dancer:Stop()
dancer:remove()
Tool.dancepart.SongLoop:Stop()
enabled = false
player.Character.Humanoid.WalkSpeed = speed
end
end
function onUnequipped()
dancer:Stop()
dancer:remove()
Tool.dancepart.SongLoop:Stop()
enabled = false
player.Character.Humanoid.WalkSpeed = speed
end
Tool.Activated:connect(onActivated)
Tool.Unequipped:connect(onUnequipped)
Hmm, Its not working. Im walking with the emote on and I am still walking with the regular walk speed and not walking slow and for extra measures i changed the speed to 0 and it still doesnt work. Would ya mind giving me the script with the variable if i made any mistakes?
the local keyword, as the name suggests, only makes an identifier local to the scope, it does not declare variables. speed = player.Character.Humanoid.WalkSpeed may not be ideal in terms of style as it declares speed as a global, but it has no problems whatsoever in terms of syntax