I'm trying to make a script that freezes the player if the intro is still active. But humanoid is underline, and there is no signs of errors in the box.
local PlayerName = game.Players.LocalPlayer.Name if game.Players.LocalPlayer.PlayerGui.ScreenGui.Main.Visible == true then game.Workspace[""..PlayerName..""]Humanoid.WalkSpeed.Value = 0 else game.Workspace[""..PlayerName..""]Humanoid.WalkSpeed.Value = 16 end
On line 4/5 you don't need the parenthesis and you would need a period after it. And I would use WaitForChild. So try this:
local PlayerName = game.Players.LocalPlayer.Name if game.Players.LocalPlayer.PlayerGui.ScreenGui.Main.Visible == true then game.Workspace:WaitForChild(PlayerName).Humanoid.WalkSpeed.Value = 0 else game.Workspace:WaitForChild(PlayerName).Humanoid.WalkSpeed.Value = 16 end
A few things here can be made more efficient, and the problem is mostly typos.
The problem is you're trying to find the player in the workspace with a string, by trying to reference it directly as though it were an object. You need to use FindFirstChild() or WaitForChild() to find an object with a string. However, these methods aren't needed here, because you can reference the character directly through the player.
local player = game.Players.LocalPlayer local character = player.Character --The character can be referenced easily through the player if player.PlayerGui.ScreenGui.Main.Visible == true then character.Humanoid.WalkSpeed.Value = 0 else character.Humanoid.WalkSpeed.Value = 16 end