Im trying to make a script for a fnaf-ish camera system. The script uses 3 textbuttons that detect the players cursor tweening it to a certain positon.
Im trying to make the script detect when the players cursor is on the left textbutton, moving the textbutton in the middle to the right so that it dosen’t get in the way for the player. While setting the visibility of the textbutton that was originally on the right to false.
local Camera = workspace.CurrentCamera
local Views = workspace:WaitForChild("Views")
local tweenService = game:GetService("TweenService")
local Button = script.Parent
local ButtonMain = game.StarterGui.View.MainView
local ButtonRight = game.StarterGui.View.ViewRight
function tweenCamera(pos,tweenTime)
tweenService:Create(Camera,TweenInfo.new(tweenTime,Enum.EasingStyle.Sine), {CFrame = pos.CFrame}):Play()
end
Button.MouseEnter:Connect(function()
if tweenCamera(Views.ViewLeft, 0.45) then
wait(1)
ButtonRight.Visible = false
ButtonMain:TweenPosition(UDim2.new(0.903, 0, 0, 0), "Out", "Sine", 0.4):Play()
end
end)
Script Placement:
I tried to do this by tweening the buttons position, but it doesn’t seem to work. Can someone help me with this?
You also have to put true or false after the time, this should cause errors without it
True means it will override any existing tween on the GUI
False means it will not override
function tweenCamera(pos,tweenTime)
tweenService:Create(Camera,TweenInfo.new(tweenTime,Enum.EasingStyle.Sine), {CFrame = pos.CFrame}):Play()
wait(tweenTime)
return true
end