Local script needs a task.wait() before it to properly work

This script won’t work without a task.wait() that has a number higher than 1 before it and i’m not sure how to fix this. Is there any way to fix this or do i just have to use task.wait()

game.Players.LocalPlayer:GetMouse().Icon = "rbxassetid://6549216050"

workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable

local ContextActionService = game:GetService("ContextActionService")
ContextActionService:UnbindAction("RbxCameraKeypress")

1 Like

If you play scripts that start earlier than the instances they require load in, you can use the function :IsLoaded() and the event .Loaded to check and wait until the game is finished loading for the player.

---Top of the script---
if not game:IsLoaded() then
	game.Loaded:Wait()
end

This will start the script only when all the instances it requires (the game) have been loaded.


Engine API for :IsLoaded()

2 Likes

It worked perfectly! Thank you for your help.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.