Hi! I have been trying to fix a bug in my game for the past three days! The bug is that whenever the player presses the play button that ive added inside my game everything freezes and the character gets removed! The wierd part about it is that everything works perfectly fine in studio. I have tried everything to fix this. The same bug goes for multiple accounts and even when i publish the same game to my testing server. Even if i try publishing a version from over a year ago the bug is still there! I have no idea how i can fix this any more and i hope that some of you guys may have either experienced this first hand or knows how to fix it. I have also used the same script for well over a year at this point with no issiue, it all started going wrong three days ago.
Here is the script making the main menu work:
–Setup
wait(1)
local tween = game:GetService(“TweenService”)
local cam = workspace.Camera
local scenes = workspace.CameraScenes
local currentTween = nil
local looping = true
–Camera Movement
while looping do
for i, v in pairs(scenes:GetChildren()) do
if looping == false then return end
cam.CFrame = v [“1”].CFrame
currentTween = tween:Create(cam, TweenInfo.new(7), {CFrame = v[“2”].CFrame})
currentTween:Play()
wait(6)
end
end
cam.CameraType = camera.CameraType = Custom was probably breaking the script(you have to use enums, strings to define types). Also you where referencing the camera as cam while the function was expecting camera I tried correcting your code syntax hoping it will fix the issue(tell me if there’re still any errors):
--Setup
task.wait(1)
local tween = game:GetService("TweenService")
local camera = workspace.Camera
local scenes = workspace.CameraScenes
local currentTween = nil
local looping = true
repeat task.wait() until camera.CameraSubject ~= nil
--Use Enums or strings to define types!
camera.CameraType = Enum.CameraType.Scriptable
--Play Button
--I expect you tried to combine two scripts? you don't have to define camera twice.
--I also renamed the camera variable above so it can be used in the function.
--((local cam = workspace.Camera) remove me)
local UI = script.Parent
UI.PlayButton.MouseButton1Click:Connect(function()
camera.CameraType = Enum.CameraType.Custom
UI.Enabled = false
looping = false
currentTween:Pause()
end)
--Camera Movement
while looping do
for i, v in pairs(scenes:GetChildren()) do
if not looping then return end
camera.CFrame = v["1"].CFrame
currentTween = tween:Create(camera, TweenInfo.new(7), {CFrame = v["2"].CFrame})
currentTween:Play()
task.wait(6)
end
end
Still wont work. I also dont think the script is the only thing thats broken as this happens even with older versions and my testing server. Thank yo for trying to help though.
Perhaps because only one tween stops(the one you reference last) how many tween are supposed to run simultaneously and what’s the intended behavior when the button “play” is pressed?