Hey devs, so im trying to get my humanoid to not move when an intro is playing. However the humanoid speed changed to 0 but the player can still move. Is this a new update from roblox or am i doing something wrong?
-- local intro = game:GetService("StarterGui"):WaitForChild("GameIntro")
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
if intro.Enabled == true and hum then
print("GAME INTRO IS ENABLED!!!!!!!!!!!!!!!!!!!!!!!")
hum.WalkSpeed = 0
print(hum.WalkSpeed)
end
Roblox likes to change the Humanoid’s walkspeed after loading. So you have to set a changed event and update it back to 0 again. (Make sure not to make it loop)
local con = humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function()
if humanoid.WalkSpeed ~= 0 then
humanoid.WalkSpeed = 0
end
end)
humanoid.WalkSpeed = 0
-- disconnect the connection when you set it back:
con:Disconnect()
hum.WalkSpeed = 16
Also the script is not under
but rather under Player.PlayerGui.GameIntro
Also another quick fix would be:
hum.WalkSpeed = 0
task.wait(5) -- you might have to change this
hum.WalkSpeed = 0
Firstly, you need to index the gui by PlayerGui, not StarterGui. StarterGui is a container which replicates its children to the Players PlayerGui (Player.PlayerGui).
Note that the if statement only runs once, so it won’t run again when the value is updated. You can use an event such as GetPropertyChangedSignal to detect when it changes and run your code then. Eg:
local player = game.Players.LocalPlayer
local playerGui = player.PlayerGui
local intro = playerGui:WaitForChild("GameIntro")
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
intro:GetPropertyChangedSignal("Enabled"):Connect(function()
if intro.Enabled ~= true and not hum then return end
print("GAME INTRO IS ENABLED!!!!!!!!!!!!!!!!!!!!!!!")
hum.WalkSpeed = 0
print(hum.WalkSpeed)
end)
So i tried without the screengui in another studio and it worked i used this
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
if hum then
hum.WalkSpeed = 0
end```
This worked but its not working in my own game and its starting to frustrate me because i know it should work
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
if hum then
local con = humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function()
if humanoid.WalkSpeed ~= 0 then
humanoid.WalkSpeed = 0
end
end)
humanoid.WalkSpeed = 0
task.wait(10) -- after the intro has ended
con:Disconnect()
end
Else using
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
if hum then
humanoid.WalkSpeed = 0
task.wait(5)
humanoid.WalkSpeed = 0
end
Finally another thing you can do is Anchor the HumanoidRootPart.
local root = char:WaitForChild("HumanoidRootPart")
root.Anchored = true