Why is this script just erroring in the output?
local Plr = game.Players.LocalPlayer
local Char = Plr.Character
Char.Humanoid.WalkSpeed = 0
Why is this script just erroring in the output?
local Plr = game.Players.LocalPlayer
local Char = Plr.Character
Char.Humanoid.WalkSpeed = 0
use
local Plr = game.Players.LocalPlayer
local Char = Plr.Character or Plr.CharacterAdded:Wait()
Char.Humanoid.WalkSpeed = 0
local Plr = game.Players.LocalPlayer
local Char = Plr.Character or Plr.CharacterAdded:Wait()
Char:WaitForChild("Humanoid").WalkSpeed = 0
You’re trying to set this when the player is created because you can set this from game/StarterPlayer
but if you’re looking to set this during the game then you could check if the character exists
So how would I fix this issue? I need it to change throughout the game though so I cannot do it manually.
What activates that piece of code?
This is what I would do:
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local function onCharacterAdded(character)
RunService.Stepped:wait()
character.Humanoid.WalkSpeed = 0
end
Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(onCharacterAdded)
end)
script.Parent.MouseButton1Down:Connect(function()
I may use this script my dev made that is shift to run:
UserInputService = game:GetService("UserInputService")
plr = script.Parent.Humanoid
while true do
if UserInputService:IsKeyDown(Enum.KeyCode.LeftShift or Enum.KeyCode.RightShift) then
plr.WalkSpeed = 35
else
plr.WalkSpeed = 25
end
wait()
end
It is located in starter character scripts and if I move it to a gui will that break it?
(I will change script.Parent.Humanoid)
Maybe this way it could work for you?
(Doing this on my phone oof)
script.parent.MouseButton1Down:Connect(function(plr)
Local char = plr.Character
char.Humanoid.WalkSpeed = 0
end)
Testing it now, hope it works!!
@Tornado_chaser04 gave me a script but it did not work, 07:30:50.510 - Players.Ulxqra.PlayerGui.LoadingScreenGui.LoadingScreenFrame.Script:43: attempt to index number with ‘Character’
Use the PlayerAdded
and CharacterAdded
functions:
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
char:WaitForChild("Humanoid").WalkSpeed = 0
end)
end)
I tested it and it worked. I could not move.
Where do I put this in a function loop
I put this in ServerScriptService.
So technically I have a loop here:
Where do I put everything?
My script:
game.ReplicatedFirst:RemoveDefaultLoadingScreen()
script.Parent.Parent.Play.Visible = false
local FirstNumber = 0
local SecondNumber = 10
local final = "Loading Extra Assets: "..tostring(FirstNumber).."/"..tostring(SecondNumber)
local object = script.Parent
object.Position = UDim2.new(0,0,0,0)
wait(1.5)
while true do
wait(math.random(0.5,3))
FirstNumber = FirstNumber +1
local final = "Loading Extra Assets: "..tostring(FirstNumber).."/"..tostring(SecondNumber)
script.Parent.Main.Text = final
if FirstNumber >= SecondNumber then
object:TweenPosition(UDim2.new(1,0,0,0), Enum.EasingDirection.In)
wait(0.1)
script.Parent.Parent.Play.Visible = true
script.Parent.Main.Text = "Loading Is Done!"
break
end
end
script.Parent.Parent.Play.MouseButton1Down:Connect(function(plr)
object:TweenPosition(UDim2.new(1,0,0,0), Enum.EasingDirection.In)
script.Parent.Parent.Play:Destroy()
for blurBye = 1, 24 do -- change blur size with 24
game.Lighting.Blur.Size = game.Lighting.Blur.Size - 1
wait(0.2) -- do not change this, this one is perfect
local Char = plr.Character
Char.Walkspeed = 0
end
end)
I need it somewhere here:
script.Parent.Parent.Play.MouseButton1Down:Connect(function(plr)
object:TweenPosition(UDim2.new(1,0,0,0), Enum.EasingDirection.In)
script.Parent.Parent.Play:Destroy()
for blurBye = 1, 24 do -- change blur size with 24
game.Lighting.Blur.Size = game.Lighting.Blur.Size - 1
wait(0.2) -- do not change this, this one is perfect
local Char = plr.Character
Char.Walkspeed = 0
end
Would this work?
plr = (reference starter character scripts).Humanoid
plr.Walkspeed = 0
My dev made a similar script it worked.
Remember to use local
before referencing plr
, unless it is inside of a function that already referenced it.
what are you even trying to do setting the walkspeed as soon as a player joins or when hes already ingame