I have problem with a horror game script

So I’m trying to make a scene when the player turns his head to the place the monster is suddenly jumpscare the sound starts playing. I’ve been told that worldtoscreenpoint can make that happen but I’m not sure how

can anyone give me an example?

Are you trying to make an animation or what?

WorldToScreenPoint returns two values:

  • Vector3 - A vector3 whose X and Y components represent the offset of the worldPoint from the top left corner of the screen in pixels.

  • Bool - If the Vector you sent is visible on the screen.

Sample script:

local RunService = game:GetService("RunService")

local Camera = workspace.CurrentCamera
local WorldPoint = Vector3.new(0, 10, 0)

RunService.Heartbeat:Connect(function()
	local Vector, IsOnScreen = Camera:WorldToScreenPoint(WorldPoint)
	
	if IsOnScreen then
		print("Vector: "..tostring(WorldPoint).." is visible on the screen")
	end
end)
1 Like

shouldn’t it have a repeat wait() or something?

as I said I’m trying to make a scene but no animations included

It’s just an example, you can use it however you think it’s better.

don’t you want it like when the monster reaches the player a animation plays the camera turns to the monster and the player dies like piggy?

1 Like

It’s not like those games… more like a story game

can you be more specific? I just want to help

2 Likes

Ok let me tell you the whole story:

First you start in an elevator and after some seconds suddenly All of the lights become off

you see a man coming right into you but the elevator’s doors start to get close and happily you will be safe

After some more seconds you will enter a floor and elevator’s doors start to open

when you are exploring the place I want when player turn his head back at the elevator he sees the man again in the elevator and doors start to get closed with a scary sound so you are locked in the place…

this is the story for now

Ohhh so you want a animation jumpscare to play when a player touches a brick the animation plays with the sound you want right?

I just want a script to fire when player sees the monster

I can make it with brick touches but the other way will be more cool

but the monster would just float and litrally look so fake

1 Like

he can just stand there and look at you while doors of the elevator closes

You can’t make it when the player sees a monster you’d need a brick part to make the monster show up

and when he jumpscares you? then what?

he doesn’t jumpscare… you just see him closing your only exit

but if you can help me with the game I would happily accept it :wink:

dude just make a a part that plays an animation animation would take like 15min at most