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

Why does my play button script get a error even tho it works fine?

Asked by
WN0C 2
3 years ago

Hello I was trying to make a PlayGui where when you join it shows you the whole map to see, and if you press Play it will destroy the Gui and move your camera to original state and play around, but my problem is it shows a error which I don't like seeing in the Output box. If someone could help me or just link a Camera thread that would help.

They are all Local Scripts and also heres the Error message prnt.sc/1qogb4y, if you don't trust links heres the message in text:

14:29:53.142 CFrame is not a valid member of Model "Workspace.Templvte" - Studio 14:29:53.142 Stack Begin - Studio 14:29:53.143 Script 'Players.Templvte.PlayerGui.PlayGui.Frame.PlayButton.Play', Line 14 - Studio 14:29:53.143 Stack End - Studio

Here are the script I used to make my Play work:

In the Play Button:

-- Locals:
local Button = script.Parent
local Camera = workspace.Camera
local Player = game.Players.LocalPlayer

Button.MouseButton1Click:Connect(function()
    if Player.PlayerGui:FindFirstChild("PlayGui") then
        Player.PlayerGui.PlayGui:Destroy()
    end

    Camera.CameraType = Enum.CameraType.Custom
    Camera.CameraSubject = Player.Character
    Camera.CFrame = Player.Character.CFrame
    Camera.CameraType = Enum.CameraType.Fixed
end)

Don't know if you need how I get into the Camera state but also heres the script:

-- Locals:
local Camera = workspace.Camera

Camera.CameraType = Enum.CameraType.Scriptable
Camera.CameraSubject = workspace.Cameras.SpawnCamera
Camera.CFrame = workspace.Cameras.SpawnCamera.CFrame

If you could improve or just tell me why it makes the error thats fine with me.

0
Which line causes the error? ChristianTRPOC 64 — 3y
0
"'Players.Templvte.PlayerGui.PlayGui.Frame.PlayButton.Play', Line 14 - Studio", "14:29:53.142 CFrame is not a valid member of Model "Workspace.Templvte" -" WN0C 2 — 3y
0
Does the script work fine? And also, Roblox is just telling you that it can not find any properties identified as "CFrame" in the model it's trying to look for. Basically, Models do not have a CFrame property. If you're reffering to parts inside the model (which do have a CFrame value), inside the model, then you'll have to add: Model.PrimaryPart or Model.Part ChristianTRPOC 64 — 3y
0
How would I do that inside a script? WN0C 2 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

The model instance doesn't have a property called CFrame, unlike Baseparts.

So like ChristianTRPOC, said set a PrimaryPart in your model and change the CFrame of the PrimaryPart.

The way I'd do this is to insert a Part into my model and position it to the center of the model and change the Transparency to 0, CanCollide to false, and Anchor to true.

PrimaryPartPropertyImage

local model1 = workspace.Model

local model1CFrame = model1.PrimaryPart.CFrame
0
When I did Player.Character.PrimaryPart.CFrame it just made my Camera go opposite of the side of my Spawn Camera in workspace? WN0C 2 — 3y
0
Never mind found a way myself thanks for the help ill accept ur answer since it helped WN0C 2 — 3y
Ad

Answer this question