soo, im trying to make a jojo game, and one of the script is one where the vampires burn on sun, but touch ended is making it impossible to detect if player is under something that blocks sunlight, soo i keep burning even if im under the roof! plz help
local service = game:GetService("ReplicatedStorage")
local folder = service:WaitForChild("Effects")
local effect = folder:WaitForChild("VFire")
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(chr)
spawn(function()
local vampire = true
local touching = false
local human = chr:WaitForChild("Humanoid")
local torso = chr:WaitForChild("Torso")
local head = chr:WaitForChild("Head")
--[[
local la = chr:WaitForChild("Left Arm")
local ra = chr:WaitForChild("Right Arm")
local ll = chr:WaitForChild("Left Leg")
local rl = chr:WaitForChild("Right Leg")
]]
local part = Instance.new("Part",head)
part.Name = "SunCheck"
part.Massless = true
part.CanCollide = false
part.Size = Vector3.new(1,50,1)
part.Transparency = 0.5
local weld = Instance.new("Weld", part)
weld.Part0 = head
weld.Part1 = part
weld.C0 = weld.C0
weld.C1 = weld.C1 * CFrame.new(0,-25.5,0)
local FireParticle = effect:Clone()
FireParticle.Parent = torso
if touching then
FireParticle.Enabled = false
else
FireParticle.Enabled = true
end
part.Touched:Connect(function()
touching = true
end)
part.TouchEnded:Connect(function()
touching = false
end)
while wait(1.5) do
if part and chr and human and torso and head and FireParticle and weld then
if not touching then
if vampire then
human:TakeDamage(15)
FireParticle.Enabled = true
end
end
else
break
end
end
end)
end)
end)

2 comments
Let the poor vampire suffer its fate. It will be over soon.
Touch events is a strange choice of how to do this in the first place. Normally, you'd do some raycasts from various body parts towards the sun, and see if the path is obstructed.