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

My onTouch part script that is supposed to burn you is not working?

Asked by 5 years ago

A script that is SUPPOSED to burn your legs if you touch the part.

How do I fix this error? No matter how many times I look at it, I personally don't see any errors.

part = script.Parent
f = Instance.new("Fire")

part.Touched:Connect(function(player)
    if player:FindFirstChild("Fire")~= nil then
    f.Parent = player
    end
    end)
0
Is the part anchored? TOP_SECRE 28 — 5y
0
I tried the script both anchored and unanchored. Still doesn't work. FearlessX96 74 — 5y
0
It sets the baseplate on fire TOP_SECRE 28 — 5y
0
Oh. I forgot to add the humanoid thingy. But it still doesn't work. I even anchored it and moved the part a little up so it's mid air and not touching anything. FearlessX96 74 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

You can do something like that.

part = script.Parent
f = Instance.new("Fire")

part.Touched:Connect(function(part)
    local plr = game.Players:GetPlayerFromCharacter(part.Parent)
    if plr and not part:FindFirstChildOfClass("Fire") then
    f.Parent = part
    end
end)


0
If its supposed to burn players only this should work. TOP_SECRE 28 — 5y
0
Can you explain it to me? Because I know there's a simple way of doing it. It's my first time seeing a different script but does the same thing. I'm still a beginner so pls explain ;-; FearlessX96 74 — 5y
0
Its the same as your script except it checks if it was touched by a player. The "part" is the limb that touched the part and its parent is your character. TOP_SECRE 28 — 5y
0
What does GetPlayerFromCharacter do? Also what's the difference between FindFirstChildOfClass and FindFirstChild? FearlessX96 74 — 5y
View all comments (4 more)
0
You can do alternative and check if parts parent(character) has a humanoid in it. part = script.Parent part.Touched:Connect(function(part) local f = Instance.new("Fire") local hum = part.Parent:FindFirstChild("Humanoid") if hum and not part:FindFirstChildOfClass("Fire") then f.Parent = part end end) TOP_SECRE 28 — 5y
0
The difference between FindFirstChildOfClass and FindFirstChild is that FindFirstChildOfClass finds by the classname aka "Fire" in your case despite its original name. So if you for example have the fire named "thingy" it will still find it because its class is still fire. TOP_SECRE 28 — 5y
0
GetPlayerFromCharacter finds a player by its character. TOP_SECRE 28 — 5y
0
GetPlayerFromCharacter is kind of vague.. What's the use of it? FearlessX96 74 — 5y
Ad

Answer this question