#i have a quick question
1 messages · Page 1 of 1 (latest)
no, this is a module script which is used by event manager
Yeah I was typing that
use the touched event
One message removed from a suspended account.
Script.parent.touched:connect(function(hit)
if not hit.parent:Findfirstchild() then;end;
One message removed from a suspended account.
Script.parent.touched:connect(function(hit)
if not hit.parent:Findfirstchild() then;end;
doesnt even work lol
bro i didnt except 5 person to answer my question at same time
btw heres code with Mimical's suggestion:
local HEsHEre = {}
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local entity = ServerStorage.Entities.HEsHEre
function HEsHEre.Trigger(player)
print("HE IS HERE")
local clonedEntity = entity:Clone()
clonedEntity.Parent = workspace
clonedEntity.Position = Vector3.new(
math.random(0, 100),
math.random(0, 100),
math.random(0, 100)
)
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
local humanoid = character:FindFirstChild("Humanoid")
local function onTouched(clonedEntitiy)
end
wait(40)
clonedEntity:Destroy()
end
return HEsHEre
U forgot to add ) after end
will it work?
deprecated wait maxin
that just wont do anything ngl
I dont see you connecting the .touched event to anything
lemme add print into onTouched
ok
the functions are there for what to do on touch, but they are still just functions on their own
U need to connect the touched event to the function
local HEsHEre = {}
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local entity = ServerStorage.Entities.HEsHEre
function HEsHEre.Trigger(player)
print("HE IS HERE")
local clonedEntity = entity:Clone()
clonedEntity.Parent = workspace
clonedEntity.Position = Vector3.new(
math.random(0, 100),
math.random(0, 100),
math.random(0, 100)
)
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
local humanoid = character:FindFirstChild("Humanoid")
local function onTouched(clonedEntitiy)
print("player touched the entity")
end
clonedEntity.Touched:Connect(onTouched)
wait(40)
clonedEntity:Destroy()
end
return HEsHEre
** You are now Level 8! **
ill do like, test
first im gonna touch the entity's hitbox then see if it printed
bruh
16:29:19.248 Workspace.Events.1_HEsHEre:15: attempt to index nil with 'Character' - Server - 1_HEsHEre:15
16:29:19.248 Stack Begin - Studio
16:29:19.248 Script 'Workspace.Events.1_HEsHEre', Line 15 - function Trigger - Studio - 1_HEsHEre:15
16:29:19.248 Script 'ServerScriptService.EventTEST', Line 26 - function activateRandomEvent - Studio - EventTEST:26
16:29:19.248 Script 'ServerScriptService.EventTEST', Line 42 - Studio - EventTEST:42
16:29:19.248 Stack End - Studio```
Btw heres what .touched does:
When you connect .touched to a base part, it'll activate on anything that touches that basepart.
So if you connect .touched to a random part, itll activate if any other part touches it, or player or anything (as long as it has cantouch on).
The parameter inside the touched function is the part that hit the basepart with the connected function. So if the player torso hit the basepart, itll be the playertorso.
then ill use different variable
If u want to check whether the part that touched the basepart is the player, you would do check the if hit.Parent has a humanoid. If it does, it means the player touched the basepart, if it doesnt, then it means another part touched the basepart
I would recommend adding some prints to the parameter for touched cause itll help you understand it much better (cause you can see what the hit part is)
um
yea
why unknown global
its supposed to match the parameter u give in the function
most people put "hit" as the param
u have clonedEntitiy or sum
TYPO
doesnt matter lol
i accidently put i
ok lemme test
u know how functions work right
local function test(hit)
print(hit)
end
test("hello")
stuff like that
parameters are inside the brackets
waiting
is it like this?
but for some reason theres Touched existed
Its not supposed to match anything old
idk lemme test it and see if anythings happen
local function onTouched(hit)
print(hit)
end
clonedEntity.Touched:Connect(onTouched)
Why do you have an if statement for touched
making duplicate variable names can cause confusion for you and the script
id honestly recommend just putting this in rq
and then test
then u can see what the touched event prints
from there u can more easily decide how to proceed
changed it
bro just removed capitalization
for your own sake id recommend naming it something different, cause it can cause you confusion in the future
no, ill notice it
No, I’ll make my life harder
ok
yea
Minimal does
If part.touched == true then
Even work?
same error
16:42:00.785 Workspace.Events.1_HEsHEre:15: attempt to index nil with 'Character' - Server - 1_HEsHEre:15
16:42:00.785 Stack Begin - Studio
16:42:00.785 Script 'Workspace.Events.1_HEsHEre', Line 15 - function Trigger - Studio - 1_HEsHEre:15
16:42:00.786 Script 'ServerScriptService.EventTEST', Line 26 - function activateRandomEvent - Studio - EventTEST:26
16:42:00.786 Script 'ServerScriptService.EventTEST', Line 42 - Studio - EventTEST:42
16:42:00.786 Stack End - Studio```
can u send ss of the output so we can have colors
local character = player.Character or player.CharacterAdded:Wait()
this part is causing the issue.
What is player?
nope
thats "Players"
not "player"
player is passed as a parameter in the function
oh wait i think its the problem at line function HEsHEre.Trigger(player)
its the problem at line 15
due to player being nil likely
do u pass a player
when u run the function
Show mimical the line where u call that function
but how am i gonna get the humanoid of the character because the character model is old roblox noob player
We're going step by step rn
How are you triggering the .Trigger function
where
show
print("EventManager script started.")
local EventsFolder = workspace:FindFirstChild("Events")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local eventsFolder = workspace.Events
local TestModule = require(eventsFolder:FindFirstChild("1_HEsHEre"))
if EventsFolder then
print("Events folder found.")
local events = {}
for _, eventModule in EventsFolder:GetChildren() do
if eventModule:IsA("ModuleScript") and string.match(eventModule.Name, "^%d+_") then
table.insert(events, require(eventModule))
end
print("Collected all of events")
end
local function activateRandomEvent()
print("Started activateRandomEvent")
if #events > 0 then
local randomIndex = math.random(1, #events)
local randomEvent = events[randomIndex]
print("Stored the event function")
if randomEvent == TestModule then
TestModule.Trigger() -- here
else
randomEvent()
print("Called other events")
end
else
warn("No valid events found in Events folder.")
end
print("Function random event is working")
end
while true do
print("Starting main loop iteration.")
task.wait(10)
task.wait(math.random(10, 15))
activateRandomEvent()
end
else
warn("Events folder not found in Workspace.")
end
Yea u dont pass any variable
in .Trigger
so thats why its nil
and why its breaking
i dont think you noticed the TestModule variable present
local TestModule = require(eventsFolder:FindFirstChild("1_HEsHEre"))
all i need to see is this
u dont pass an argument
while there is a parameter in the function inside the module
Mich you need to put the player in the brackets
bro, it worked before
when i tested without the player checking if it touched part
the entity cloned then put in workspace then teleported
.
which function?
trigger
in module script (where HEsHEre event is present) or event manager script?
module
ok
its not gonna be a perm print, so its fine to not have a clear print
it printed "nil"
but how am i gonna get the humanoid of the player?
What?
We are talking about passing the player when we trigger the function
we arent talking about getting the humanoid
i dont know how to do that
is event manager local or server
Same way you pass any variable to function
server
the entity appear for everyone and when someone touches it, it'll trigger jumpscare screen in everyone's screen
ok
local HEsHEre = {}
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local entity = ServerStorage.Entities.HEsHEre
function HEsHEre.Trigger()
print("HE IS HERE")
local clonedEntity = entity:Clone()
clonedEntity.Parent = workspace
clonedEntity.Position = Vector3.new(
math.random(0, 100),
math.random(0, 100),
math.random(0, 100)
)
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
local humanoid = character:FindFirstChild("Humanoid")
local function onTouched(hit)
if clonedEntity.Touched == true then
print(hit)
end
end
clonedEntity.Touched:Connect(onTouched)
wait(40)
clonedEntity:Destroy()
end
return HEsHEre
okay cool u removed the parameter
yea so currently u dont need anything related to the humanoid
u connect a touched event to the part thats spawned
with that u want to check whether the player touched the part
ill tell u how to do that in a sec
but first
remove this
lemme switch that to clonedEntity
okay it fixed
cool
okay whats next step
now next step is to remove the if statement inside onTouched, cause the function only triggers when u touch the part so its irrelevant
After that i want you to add the following in the function:
print(hit)
print(hit.Parent)
and press play to see what it prints out
Im doing this so you can visualize better what exactly the hit variable is
U can move it if u go server side
i disabled by doing this
Just make sure its base position is reachable
um what, it didnt print anything when i touched its hitbox
u dont need that if statement i said btw
in developer console, i mean the roblox studio one
since the function only triggers if the part is touched
(ignore that other infinite yeild warn)
Can u send video
ok lemme send video since i have nitro (lasts for 1 hour right now)
ok uploading
i need to eat so be right back and you can anylaze the video
heres the video
canTouch is enabled
okay
Btw quick tip: use debrisservice for this
Secondly can you change the onTouched function to this please?
local function onTouched(hit)
print(hit)
print(hit.Parent)
end
without the if statement
ok im back
alr it worked when i touched the entity's hitbox
i see me next to the entity walking next to it with those spamming print
Im talking specifically the prints
and when i stop walking, the spam print stops
What are they printing
they print these
17:19:45.370 michaelamgad - Server - 1_HEsHEre:17
17:19:45.482 Right Arm - Server - 1_HEsHEre:16
17:19:45.486 michaelamgad - Server - 1_HEsHEre:17
17:19:45.488 Torso - Server - 1_HEsHEre:16
17:19:45.492 michaelamgad - Server - 1_HEsHEre:17
17:19:45.495 head - Server - 1_HEsHEre:16
17:19:45.500 michaelamgad - Server - 1_HEsHEre:17
17:19:45.502 Right Leg - Server - 1_HEsHEre:16
17:19:45.506 michaelamgad - Server - 1_HEsHEre:17
17:19:45.507 Left Arm - Server - 1_HEsHEre:16
17:19:45.511 michaelamgad - Server - 1_HEsHEre:17
17:19:47.449 Right Leg - Server - 1_HEsHEre:16
17:19:47.453 michaelamgad - Server - 1_HEsHEre:17```
Yea i am aware
but what exactly are they
Like what is "Left Leg"
like that
try to find it in the explorer
its in old roblox noob character model
michaelamgad what about this
what the mainSCRIPT does is that it places everything below into its position where 2007 roblox engine works except for unused content
as you can see in the video, when i press start. everything gets replaced with old 2007 roblox engine
including the erik.cassel model
in workspace as the model
Yea
after pressing play, the model named "michaelamgad" appeared
So based on that knowledge, how can you get the humanoid?
in michaelamgad.humanoid
Yea
Btw rq whats your goal again inside the .Touched function?
What are you trying to do?
well i want the jumpscare screen to appear which is this for 1 second then disappears and the entity itself disappears
Okay so with the .Touched event you have achieved the ability to run code when the entity is touched
What you would want to do now, is check whether the part that touched the entity is the character (u can do this by checking for humanoid). After that you run the jumpscare on the character
um it already activates when the player touches the entity's hitbox
without adding the check
Yea but it currently would also activate if another random part happened to touch the entity
So you just need to add a check to make sure it was the character that touched the entity
ok
is this correct check?
local function onTouched(hit)
if hit.Parent:FindFirstChild("Humanoid") then
for _, player in Players:GetPlayers() do
local jumpscareGUI = StarterGui.CreepyMessages.IAMWATCHINGYOU
local jumpscareSound = SoundService.JUMPSCARE
jumpscareGUI.Visible = true
jumpscareSound.Playing = true
wait(2.4)
jumpscareGUI.Visible = false
clonedEntity:Destroy()
end
end
end
** You are now Level 9! **
yes that checks it correctly
Btw as you mightve seen in the prints, whenever the player hits the entity, it sent multiple prints for different limbs
This will make it so the .touchedevent can trigger multiple times
To combat this i would recommend either adding a debounce or disconnecting the function once the character hit it
bro, the gui wont appear on my screen
when u press play the startergui gets replicated into the player inside the playersfolder
player.PlayerGui
okay
here are the results of this HEsHEre event (uploading the video)
So it works now?
bro the entity's hitbox is 50 studs large
u can change that
its not supposed to trigger if the player touched its old hitbox which is 4 studs big
i mean
the HEsHEre part is 50 studs large
u can make an invisible hitbox for the actual hit and the entity itself can be bigger (with canTouch off)
oh wait i think 50 studs big is not big enough
lemme make it 75 studs big
and done
ok i think the event itself is done. Thank you for helping me @drowsy rivet
Cool nws
it also worked with teleport function
after the entity teleported to random position, i ran to it then touched it then the jumpscare worked