Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Fire script that makes the player take damage from fire, doesn't work. Anyway I can fix this?

Asked by 5 years ago

This is the third time I am asking this question and I apologize if this is a hassle for anyone, but It's a project that I need assistance on. So i've tried all suggestions but so far no difference has been made. The player lights up in flames, but they still take no damage what so ever. This is the script:

local firePart = script.Parent

local Players = game:GetService("Players");

firePart.Transparency = 1

local function LightOnFire(part)

local fire = part:FindFirstChild("Fire")

if not fire then

fire= Instance.new("Fire")

fire.Parent = part

local client = Players:GetPlayerFromCharacter(part.Parent)

if (client) then

local health = client.Character.Humanoid.Health

health = 100

health = health - 15

wait(3)

end

end

end

firePart.Touched:connect(LightOnFire)

0
I reposted my answer^ GodOf_Lua 25 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Here a solution:

  local firePart = script.Parent

local Players = game.Players

firePart.Transparency = 1

function LightOnFire(hit)

local fire = hit.Parent:FindFirstChild("Fire")

if fire then

else

local FireInstance = Instance.new("Fire")

if hit.Parent:FindFirstChild("Humanoid") then

FireInstance.Parent = hit.Parent.HumanoidRootPart

local Humanoid = hit.Parent:FindFirstChild("Humanoid")

repeat

wait(3)

Humanoid.Health = Humanoid.Health -15

until Humanoid.Health <= 0

print("f")

end

end

end

firePart.Touched:Connect(LightOnFire)

Actually you didn't checked for the humanoid so it didn't found it probaly. This one should work. I tested it.

0
sorry for the very very late reply. I almost gave up on working on this all together. I am afraid that one didn't work for me either, and I am at a lost of what to do. I really wanna get better at lua but its kinda hard when you really don't know where to start or how to fix simple issues such as this, dragonspade21 15 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

here is a solution

    script.Parent.Touched:Connect(function(hit)

if hit.Parent:FindFirstChild("Humanoid") then

hit:FindFirstChild("Fire"):Clone().Parent = hit.Parent

end

while true do

if hit.Parent:FindFirstChild("Fire") then

hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 15

wait(0.5)

end

end

end)
0
Honestly, this might be the answer, but am not sure. When I tried your code, everytime I touch the object, my computer freezes instead for like 5 seconds dragonspade21 15 — 5y

Answer this question