I want to make a ray cast for a laser that burns the character if detected, however, around this point:
if you’re on top of the elevator and go and touch the laser, nothing happens, no player burned, which is strange because when the elevator was at a higher position it would burn the character.
I’ve tried changing the direction position to see if that changes anything but to no avail, I do not know what else to do. Also, when im printing the hitpart position, the printed position freezes even though the elevator is moving, as soon as this position freezes and I walk on top of the laser, touching it, I don’t get burned. This is my script:
function characterBurner()
local tweenInfo = TweenInfo.new(
5,
Enum.EasingStyle.Linear
)
repeat
task.wait()
local characters = {}
for _, v in next, game.Players:GetPlayers() do
table.insert(characters, v.Character)
end
local rayOrigin = elevatorChamber.Parent.Laser2.Laser.Position
local rayDirection = Vector3.new(0, -102, 0)
raycastParams.FilterDescendantsInstances = {elevatorChamber.laserAbsorber, characters}
raycastParams.FilterType = Enum.RaycastFilterType.Whitelist
local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams)
local rayOrigin2 = elevatorChamber.Parent.Laser.Laser.Position
local rayDirection2 = Vector3.new(0, 28, 0)
raycastParams2.FilterDescendantsInstances = {elevatorChamber.laserAbsorber2, characters}
raycastParams2.FilterType = Enum.RaycastFilterType.Whitelist
local raycastResult2 = workspace:Raycast(rayOrigin2, rayDirection2, raycastParams2)
if raycastResult then
local hitPart = raycastResult.Instance
if hitPart:FindFirstAncestorWhichIsA("Model") then
local character = hitPart:FindFirstAncestorWhichIsA("Model")
if character:FindFirstChild("Humanoid") then
if not character.HumanoidRootPart:FindFirstChild("Fire") then
local fire = Instance.new("Fire")
fire.Parent = character.HumanoidRootPart
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://138077028"
sound.Parent = character.HumanoidRootPart
sound.Volume = 1
sound.RollOffMaxDistance = 100
sound:Play()
local immolation = function()
while character.Humanoid.Health ~= 0 do
for _, v in next, character:GetChildren() do
if v:IsA("BasePart") then
local Goal = {Color = Color3.fromRGB(255, 0, 0)}
tweenService:Create(v, tweenInfo, Goal):Play()
end
end
character.Humanoid.Health -= damageIncriment
task.wait(waitTime)
end
end
task.spawn(immolation)
end
end
end
end
if raycastResult2 then
local hitPart = raycastResult2.Instance
print(hitPart.Parent, hitPart.Position)
if hitPart:FindFirstAncestorWhichIsA("Model") then
local character = hitPart:FindFirstAncestorWhichIsA("Model")
if character:FindFirstChild("Humanoid") then
print("found humanoid")
if not character.HumanoidRootPart:FindFirstChild("Fire") then
local fire = Instance.new("Fire")
fire.Parent = character.HumanoidRootPart
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://138077028"
sound.Parent = character.HumanoidRootPart
sound.Volume = 1
sound.RollOffMaxDistance = 100
sound:Play()
local immolation = function()
while character.Humanoid.Health ~= 0 do
for _, v in next, character:GetChildren() do
if v:IsA("BasePart") then
local Goal = {Color = Color3.fromRGB(255, 0, 0)}
tweenService:Create(v, tweenInfo, Goal):Play()
end
end
character.Humanoid.Health -= damageIncriment
task.wait(waitTime)
end
end
task.spawn(immolation)
end
end
end
end
until elevatorChamber.Laser.Attachment.Beam.Enabled == false
end
laserAbsorber position: (-61.643, 92.958, 650.23)
laserAbsorber2 position: (-61.643, 28.083, 650.23)
Printed position of when laserAbsorber.Position freezes even though the elevator
the elevator is moving: (-61.643001556396484, 14.552589416503906, 650.22998046875)
Position of the elevator before it starts moving (this is the position of where the elevator is tweened to): -61.643, 28.87, 650.23
Position of the elevator once it reaches the bottom: (-61.643, -168.877, 650.23)
This is an image of “laserAbsorber” (I know my script can use some more functions to keep cleaner but I’ll do that later once I find a solution to this issue)