Hi, I'm trying to script a torch that turns its visibility on when a fireball projectile enters its trigger.
The script I have is..
local TRIGGER = script.parent
local TORCH_FIRE_VFX = script:GetCustomProperty("TorchFireVFX"):WaitForObject()
local FIREBALL = script:GetCustomProperty("Fireball")
function OnBeginOverlap(TRIGGER, other)
if other:IsA("Fireball") then
print(TRIGGER.name .. ": Begin Trigger Overlap with " .. other.name)
TORCH_FIRE_VFX.visibility = Visibility.FORCE_ON
FIREBALL.Destroy()
TRIGGER.Destroy()
end
end
TRIGGER.beginOverlapEvent:Connect(OnBeginOverlap)
Any help would be greatly appreciated
Thanks
Hey Junior, the :IsA() function detects specific API types that are defined in Core, such as "CoreObject", "Trigger", "Player" or in this case "Projectile". There is no defined type for "Fireball" and you can't define a new one.
Another issue with your script is that functions like :Destroy() should be called with ":" not "."
One approach to this problem would be to use the name of the other object. Start by printing out the name of the "other"--like you are already doing, just remove the line "if other:IsA("Fireball"...
Once you are confident the projectile is actually hitting the trigger and you see the name in the Event Log window, then add back the "if", it should say something like:
if other.name == "Fireball" then