Part returning as nil from BindableEvent

i have a serversided bindableevent that returns a part and another script that checks if the part still exists after an amount of time has passed.

heres the script that creates and returns the part:

game.ReplicatedStorage.ServerHitbox.Event:Connect(function(part,size,player)
	local weld = Instance.new("Weld")
	local Hitbox = script.Hitbox:Clone()
	weld.Parent = Hitbox
	Hitbox.CFrame = part.CFrame
	Hitbox.Size = size
	weld.Part0 = Hitbox
	weld.Part1 = part
	Hitbox.Parent = workspace.Hitboxes
	Hitbox:SetAttribute("IsServersided",true)
	Hitbox:SetAttribute("Owner",player.Name)
	return Hitbox
end)

and heres the script that checks if the part is still existing:

local Hitbox = game.ReplicatedStorage.ServerHitbox:Fire(Player.Character[animFolder.C1.Hitbox.Value],Vector3.new(5,5,5),Player)
if Hitbox == nil then
			Player.Character.Combo.Value += 1
		else
			Hitbox:Destroy()
		end

the Hitbox value returns as nil even though the object is clearly visible in the hitbox folder

help would be appreciated!!!

I don’t think BindableEvents returns anything when calling :Fire(), even if you return something in the connected function. I believe what you are looking for is a BindableFunction object instead. BindableFunctions would be able to return values like you want.

Here’s documentation for it:
BindableFunction | Roblox Creator Documentation

Completely forgot about that, thanks!

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