Hi, I am currently making a script using a camera for my main menu, but weirdly, it doesn’t work like it’s supposed to. I tried using the Studio’s AI Assistant thing but no matter how many times I’ve asked, it still doesn’t want to run. I’ve also searched everything in the DevForum, but still, none of them seem to work.
It consists of two scripts,
Here’s the main script (“Camâ€, works just fine):
--overall sets the camera to its position; CamPart.
local camPart = workspace:WaitForChild("CamPart")
local camera = workspace:WaitForChild("Camera")
local gui = game.StarterGui:WaitForChild("MainMenu")
function tween(obj, dur, cmd)
return game:GetService('TweenService'):Create(obj, dur, cmd)
end
workspace.Camera.CameraType = Enum.CameraType.Scriptable
local cameraTween = tween(camera, TweenInfo.new(3), {CFrame = camPart.CFrame})
cameraTween:Play()
cameraTween.Completed:Connect(function()
game:GetService("RunService").RenderStepped:Connect(function()
camera.CFrame = camPart.CFrame
end)
end)
and here’s the 2nd script (“LocalScriptâ€), which I am having trouble with:
local gui = game.StarterGui.MainMenu
local camPart = workspace:WaitForChild("CamPart")
local button = script.Parent
local camera = workspace.Camera
-- return the camera to player
button.MouseButton1Click:Connect(function()
--making sure it works
print("returnplayer executed")
gui.Enabled = false
--returning camera to player
camera.CameraType = Enum.CameraType.Custom
camera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
print("success")
end)
Now, weirdly, the print function works just fine, but hiding the GUI and returning the camera to the player doesn’t work.
Here’s the hierarchy of the properties
Here’s what it looks like:
Waiting for your help!
4 posts - 2 participants