So when I start the game in Studio, there’s a delay before the game starts, and in realtime, the game just freezes. There are some things I think could be the issue:
Most scripts start with ;
wait()
local player = game.Players.LocalPlayer
local char = workspace:WaitForChild(player.Name)
local Humanoid = char:WaitForChild(“Humanoid”)
local HRP = char:WaitForChild(“HumanoidRootPart”)
local T = char:WaitForChild(“Torso”)
If this is about scripting, then it belongs in #development-support:scripting-support. You will be able to get more help there. You should be able to move it in the settings under the topic.
You should never have a wait at the beginning of your script, regardless of what it is. This is a code smell which is a programming anti-pattern. Use yielding functions and an event-driven code base to work through your issues. Other than that, your code has a few noticeable issues practice wise:
Are you adding a wait because of the LocalPlayer index? LocalPlayer implicitly exists for LocalScripts. Any kind of yield is unnecessary.
Don’t find the character by searching the Workspace for an instance named a player. It’s not canonically correct and it can produce edge cases for conflicting names.
Use clear variable names for the sake of readability and maintainability. Try to avoid one-letter variable names as well as short and undescriptive names.
GetService is the canonical method to retrieve services.
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
-- Rest of your WaitForChilds here: use Humanoid, RootPart and Torso
I believe wait at the top of scripts is an artifact of when certain edge cases existed in some ancient old pre-2015 game code (not sure what, but I remember it being in CoreScripts back in ye olde’ days)
This probably isn’t the entirety of your code or a good enough portion. Can you provide more information? Is this in a loop? Just because you think it’s the issue doesn’t mean it is.
That is a lot of localscripts, but I don’t think those are the issue unless they are all running at once. I was expecting actual code however. This complicates things. You’re going to need to go through each and tell me what they’re each doing.