Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My GUI's Frame Isn't Appearing After The Camera Changes!?

Asked by
colivs 2
5 years ago

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)

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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)
0
Thank You Very Much! colivs 2 — 5y
Ad

Answer this question