I'm using BindableEvent to make it so the script fires signal and other script inside other modulescript detects it. but I got problem

hello there again, I’m trying to make the thing so the Despawnscript will fire an Bindable Event before it deletes(despawns) it’s humanoid model, and the script named RespawnScript inside one modulescript insdie that same humanoid model Detects the fired event and Runs itself so the humanoid model respawns, it will use the BindableEvent as I said earlier, but I do not know how to make it properly, so I need your help once again, first I will show you two code block featuring DespawnScript and RespawnScript, and I wish you that you would fix it for me.

--the despawnscript, inside the humanoid model.
local event = game.ServerStorage.BossRespawn.GigantiumGoblinRespawn
task.wait(120)
event:fire()
wait(0.07)
script.Parent:Destroy()
--the respawnscript, inside the modulescript inside the same humanoid model.
local _M = require(script.Parent.MobConfig)
local Mob = script.Parent
local Enemy = Mob.Enemy
local event = game.ServerStorage.BossRespawn.GigantiumGoblinRespawn

MobClone = Mob:Clone()

function Respawn()
	if (not Mob) then return end
	script.Parent:BreakJoints()
	wait(_M.RespawnTime)
	script.Parent:Destroy()
	MobClone.Parent = workspace:WaitForChild("Mobs")
	MobClone:MakeJoints()
end	

Enemy.Died:Connect(Respawn)
	or else if  event.Event:Connect(function()
			Enemy.Died:Connect(Respawn)
		end)
	end
end --I have no idea how can I make this specific part work, so please change the script so it will work as desire, thank you.

sorry for this messy script through, but if you’re able to fix that script for me, I will be glad to make it work. thank you. :hugs:
-mari

2 Likes

If I understand your script and intentions correctly, you don’t need that entire “or else if” block. The purpose of :Connect() is to “connect” a function to an event when it fires. So for example, if you have an event ABC, and you want to execute function DEF when that happens, you would do:
ABC:Connect(DEF). In your situation, your script’s logic is “connect to Respawn, or if some other event fires, connect to Respawn”. That logic is unnecessary and you should be fine with just Enemy.Died:Connect(Respawn).

2 Likes


hello there, I have deleted the “or else if”, but it seems like it still have an script error, and I have no idea how could I fix that, so if you could, please help me with this, I thank for you for your convenience.
-mari

You don’t need lines 19 and 20 I think.

1 Like

the current problem going on in my game, I deleted line 19 and 20 through
thank you for the suggestion through, but however the main problem is related to the DespawnScript as I think, the despawnscript does not do anything other then destroying it’s parents, it does not send signal to respawnscript at all. so I want to make despawnscript have code that fires bindableEvent and respawnscript reads it, sorry for the inconvenience.
-mari

1 Like

Can I see despawnscript? How are you sending the event to the respawnscript? Maybe there’s an issue in that, also judging by the screenshot, RespawnScript is disabled.

1 Like

If the despawn script destroys the model and the respawn script is inside…
Place them inside playersvripts to ensure their persistence regardless of the actual state of the character.

why hello there again, so here is despawnscript as you said, also may I just send you the the test game file including that boss monster humanoid model with despawnscript and respawnscript inside? and may you could fix it so despawnscript fires the BindableEvent before it destroys the parent. and therefore respawnscript reads the event triggered and it runs itself before the parent gets destroyed, so anyway here is code of despawnscript, tell me if you want the studio game file. (there is some unfinished things in the test game so I’m going to fix these after solve this current problem.)

--the despawnscript
local event = game.ServerStorage.BossRespawn.GigantiumGoblinRespawn
task.wait(50) --in above line it was supposed to fire an BindableEvent, but I deleted it for now.
script.Parent:Destroy()

-mari

hello there, as it seems that you’re not responding, may I send you the studio file of that test game I have mentioned, it would be awesome if you could fix that despawn and respawnscript only but it’s up for your choices. so here you go.
Mari’s script test 1.rbxl (477.7 KB)

thank you. -mari

Hi, I’m sorry for not responding as I’m currently very busy in life and can’t open the devforum, and when I do, I’m usually on mobile. If I understand correctly, you want to make a bindable event that, on fire, will destroy the parent of a script?

Edit: looks like you want to fire an event too, you can do that by calling :Fire() on the event you want to fire

actually, I want to make it so the bindableEvent triggers other script inside the same model as script which fired the bindableEvent so basically script named DespawnScript fires an BindableEvent and the RespawnScript Detects the fired BindableEvent, that’s what I’m hoping to work. instead of it destroying the parent of a script when event is fired.
-mari

Well then if you just want to fire a bindable event from one script and receive it in the other it’s as simple as:

DespawnScript:

local event = game.ServerStorage.BossRespawn.GigantiumGoblinRespawn
event:Fire()

RespawnScript:

local event = game.ServerStorage.BossRespawn.GigantiumGoblinRespawn
event.Event:Connect(function()
    --your code here!
end)

As per BindableEvent documentation. It is a better place to find information than the DevForum, but you’re always welcome to post here again if you have any issues.

1 Like

hello there yet again! I have used these things you have mentioned in last reply, but through there is still an Error named
“Fire is not a valid member of RemoteEvent “ServerStorage.BossRespawn.GigantiumGoblinRP” - Server - DespawnScript:3”

anyway I also have video of the footage of that test gameplay, but it didn’t work properly and showed error code shown as above through, thank you for your convenience.
the video of that test game, however it still have an errors going on.

thank you so much. -mari

Is ServerStorage.BossRespawn.GigantiumGoblinRP a BindableEvent? If not, replace it with the path to the event. And also, are you using .Fire() or :Fire()? Only the second one is correct.

hello there IAmVo! the most of the things worked as I desired after I realized I had to use actual thing named BindableEvent instead of RemoteEvent, damn I was stupid. anyway I had to tweak the code so it replenishes the Health of the boss monster instead of breaking it’s joint and making an new one, but however, when I tried to also make it so the respawnscript teleports the GigantiumGoblin model(the boss model) into part in workspace named “GigantiumGoblinRespawnCoords” but things didn’t actually come in handy, so here is the code again. thank you.

local event = game.ServerStorage.BossRespawn.GigantiumGoblinRP
local _M = require(script.Parent.MobConfig)
local Mob = script.Parent
local Enemy = Mob.Enemy

MobClone = Mob:Clone()

function Respawn()
	if (not Mob) then return end
	script.Parent:BreakJoints()
	wait(_M.RespawnTime)
	script.Parent:Destroy()
	MobClone.Parent = workspace:WaitForChild("Mobs")
	MobClone:MakeJoints()
end	

Enemy.Died:Connect(Respawn)

event.Event:Connect(function()
	Enemy.Health = 124 --it replenishes the health of boss upon "despawnscript" fires an BindableEvent, instead of reseting the boss model.
	Mob.Parent.WorldPivot.Position = workspace.GigantiumGoblinRespawnCoords.CFrame + Vector3.new(0, 0.69, 0) --this line was supposed to teleport the entire GigantiumGoblin Model into part in workspace named "GigantiumGoblinRespawnCoords". but it's not working.
end)

anyways thanks for spending your time for help me out, it really helps me with fixing it :wink: -mari

1 Like

Well, if everything works, please mark my answer that helped you the most as a Solution, and I was glad to help (albeit it formed a 16 message long thread, my apologies for that). If something still isn’t clear, feel free to message me or this thread. (or create a new one to prevent going “off topic”)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.