this script is for making a gui appear, music play, and camera change when you touch a part. that part works, but i think it works too many times as when you touch the part, it appears for a second, then crashes the game/studio..
i think the problem is the debounce, and it is not working correctly. i get no errors from this script either, but any help is really appreciated.
debounce = false
function onTouched(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player and debounce == false then
debounce = true
player:WaitForChild("PlayerGui").Credits.Frame.Visible = true
end
local Camera = game.workspace.CurrentCamera
workspace.ramp.Touched:Connect(onTouched)
Camera.CameraType = "Scriptable"
Camera.CFrame = game.workspace.CamPart2.CFrame
end
local debounce = false
Music = script.credits
STAR = game.SoundService.STAR
workspace.ramp.Touched:connect(function(hit)
if not hit.Parent:FindFirstChild("Humanoid") then return end
debounce = true
Music:Play()
STAR:Pause()
workspace.ramp.Touched:Connect(onTouched)
debounce = true
game.Workspace.ramp.CanCollide = false
game.Workspace.mainwall.CanCollide = true
end)
EDIT: Shortened my plea for help

5 comments
Are you sure the error is coming from this script and this part?
i am pretty sure, this is the only script i've been working on, and the game only crashes when you touch the part which the script is referencing but i can't check for errors as the game crashes
it is a problem with the debounce
also i can't really fix your problem because your code is just formatted so weird i have no clue which part belongs under where
thank u, i will try to fix the formatting and the debounce problem, but atleast now i know what the problem is