I want to make a jumpscare play then make the game wait a few seconds then send the player to the main menu that is a surface GUI that can be seen by making a different part the camera (Witch is already done)
The problem is that I just don’t have the scripting knowledge to piece that together.
I tried to make that work using AI (ChatGPT) I know that ChatGPT scripts don’t work most of the time cuz of a few mistakes witch I fix before testing, but there was no luck this time. I couldn’t really find an another solution.
This is what I have written so far:
The jumpscare:
--The child of the script is the animation the entity plays--
local cam = game.Workspace.CurrentCamera
local camPart = game.Workspace.JumpscareBox.JumpscareCam
local jumpscareTime = 5
local lighting = game.Lighting
local Screen = game.StarterGui.KillEffect.Frame
local Animation = script.Animation
local NPC = game.Workspace.JumpscareBox.a
local Player = game:GetService("Players")
local Spook = game.Workspace.SFX["FEAR HIT 04"]
local sound = game.Workspace.SFX.Jumpscare
local remote = game.ReplicatedStorage.Jumpscare
remote.OnClientEvent:Connect(function()
repeat
cam.CameraType = Enum.CameraType.Scriptable
until cam.CameraType == Enum.CameraType.Scriptable
local startTime = tick()
cam.CFrame = camPart.CFrame
local Anim = NPC.Humanoid:LoadAnimation(Animation)
Anim:Play()
Screen.Visible = true
lighting.ColorCorrection.Brightness = -0.2
Spook:Play()
sound:Play()
repeat
wait()
local endTime = tick()
local randX = math.random(-300,150) / 500
local randY = math.random(-300,150) / 500
local randZ = math.random(-300,150) / 500
cam.CFrame = cam.CFrame * CFrame.Angles(math.rad(randX), math.rad(randY), math.rad(randZ))
until endTime - startTime >= jumpscareTime
cam.CameraType = Enum.CameraType.Custom
cam.CameraSubject = Player
lighting.ColorCorrection.Brightness = 0
end)
The script in the hitbox part that triggers the jumpscare:
--There is a remote event in Replicated Storage named Jumpscare--
local hitbox = script.Parent
local cooldown = false
local remote = game.ReplicatedStorage.Jumpscare
hitbox.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
if not cooldown then
local human = plr.Character.Humanoid
if human.Health > 0 then
cooldown = true
human.Health = 0
remote:FireClient(plr)
wait(2)
cooldown = false
end
end
end
end)```
AND the script for the main menu itself:
–// Variables
local Sounds = game.Workspace.MainMenu.SFX
local player = game.Players.LocalPlayer
local pb = game.Workspace.MainMenu.Main.MainMenu.MainFrame.Buttons.Play
local cam = workspace.CurrentCamera
local camPart = workspace[“CameraPart”]
local mouse = game:GetService(“Players”).LocalPlayer:GetMouse()
–// Set cam
repeat
wait()
cam.CameraType = Enum.CameraType.Scriptable
until
cam.CameraType == Enum.CameraType.Scriptable
–// Move cam
local maxTilt = 5
game:GetService(“RunService”).RenderStepped:Connect(function()
cam.CFrame = camPart.CFrame * CFrame.Angles(
math.rad((((mouse.Y - mouse.ViewSizeY / 2) / mouse.ViewSizeY)) * -maxTilt),
math.rad((((mouse.X - mouse.ViewSizeX / 2) / mouse.ViewSizeX)) * -maxTilt),
0
)
end)
–PlayFunction–
pb.MouseButton1Click:Connect(function()
Sounds.Click:Play()
end)
Now this is a lot I'm asking here, but I was simply left with no other choice, I've been working on this problem for a month and a half now and it would help the game greatly if someone came up how to combine all this together.
The person who will teach me how to make one script go to an another will deserve their own place in the Credits section. I know it's not much but it's the best I can do as a reward.