hi there, I’ve posted about this before but I figured I’d do it again since I didn’t really understand how to do it so I’m asking again to see if I can get more advice I could understand easier.
again, I’m trying to make a slender man game on Roblox, so I wanna make a static GUI appear once slender man is being looked at by a player. Any help is greatly appreciated since nobody else wants to help
You could use WorldToScreenPoint to check if “slender’s” position is visible on the players screen. However, it will still return true even if the point is blocked by parts or terrain. If this isn’t what you want, you’ll need to lookup and learn raycasting.
Below is just a dummy with a humanoidRootPart in workspace.
Example of it in use:
-- This is a local script in startergui
-- Variables --
local WS = game:GetService("Workspace");
local Camera = WS:WaitForChild("Camera");
local DummyRootPart = WS.Dummy.HumanoidRootPart; -- For this example we want to see if the dummies humanoidRootPart is visible on the players screen
-- Loop --
while wait()do -- I'm using a while loop for the example
local Position, CanSee = Camera:WorldToScreenPoint(DummyRootPart.Position); -- WorldToScreenPoint returns a vector3 and bool value. You really only need to use the bool value.
if CanSee then
print("I can see the dummy. Do random UI effectsz");
else
print("Can't see the dummy. Do nothing or disable effects");
end;
end;
See in my example where it shows print("I can see the dummy. Do random UI effectsz"). You can quite literally just do MyStaticGui.Visible = true and where print("Can't see the dummy. Do nothing or disable effects"), just put do MyStaticGui.Visible = false.
Note that MyStaticGui is the reference to the gui you want to show.
The example script was a local script in starterGui. You could just put it in the UI itself (assuming the GUI is in StarterGui or any other place where local scripts can run).