I'm new to scripting, but i've tried hours on this and nothing will work.. so far in studio the changing camera part works and changing song part works, but only in studio, not in game. so nothing of this works, but i get no errors! can anyone please tell me problems with the script, i need help
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 debounce = false end end local Camera = game.workspace.CurrentCamera script.Parent.Touched:Connect(function (hit) Camera.CameraType = "Scriptable" Camera.CFrame = game.workspace.CamPart2.CFrame end) local debounce = false Music = script.credits STAR = game.SoundService.STAR script.Parent.Touched:connect(function(hit) if not hit.Parent:FindFirstChild("Humanoid") then return end debounce = true Music:Play() STAR:Pause() end) local debounce = false script.Parent.Touched:Connect(function (hit) debounce = true game.Workspace.mainwallz.CanCollide = true end)
This doesn't work because you used a server script, the camera, guis and everything related to the player can only be accessed with a local script. Try using a local script instead, and place it in the StarterPlayerScripts. And you can connect a function by its name, not by its argument (the thing in parenthesis).
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 debounce = false end end local Camera = game.workspace.CurrentCamera workspace.PARTHERE.Touched:Connect(onTouched) Camera.CameraType = "Scriptable" Camera.CFrame = game.workspace.CamPart2.CFrame end) local debounce = false Music = script.credits STAR = game.SoundService.STAR workspace.PARTHERE.Touched:connect(function(onTouched) if not hit.Parent:FindFirstChild("Humanoid") then return end debounce = true Music:Play() STAR:Pause() end) local debounce = false workspace.PARTHERE.Touched:Connect(onTouched) debounce = true game.Workspace.mainwallz.CanCollide = true end)