I'm Trying To Make This Code Where When The Camera Changes the Frame Of The gui (local shop) Appears, But It Isn't, why?
LocalScript In StarterPlayerScripts
local present = game.ReplicatedStorage.PresentModel local shop = game.StarterGui:WaitForChild("Shop") workspace.Part.ClickDetector.MouseClick:connect(function() local Player = game.Players.LocalPlayer local Character = Player.Character or Player.CharacterAdded:Wait() local Camera = workspace.CurrentCamera repeat wait() Camera.CameraType = Enum.CameraType.Scriptable until Camera.CameraType == Enum.CameraType.Scriptable Camera.CFrame = workspace.CameraSpawns.CameraPart.CFrame print("Changed") local localpresent = present:Clone() localpresent.Parent = workspace shop.Enabled = true end)
On line 2, you use StarterGui
. This will not work as StarterGui
only copies into your player's PlayerGui
when you respawn or join the game.
Use your own player's PlayerGui
, as it is guaranteed to show the changes you make.
local present = game.ReplicatedStorage.PresentModel local shop = game.Players.LocalPlayer.PlayerGui:WaitForChild("Shop") workspace.Part.ClickDetector.MouseClick:connect(function() local Player = game.Players.LocalPlayer local Character = Player.Character or Player.CharacterAdded:Wait() local Camera = workspace.CurrentCamera repeat wait() Camera.CameraType = Enum.CameraType.Scriptable until Camera.CameraType == Enum.CameraType.Scriptable Camera.CFrame = workspace.CameraSpawns.CameraPart.CFrame print("Changed") local localpresent = present:Clone() localpresent.Parent = workspace shop.Enabled = true end)