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

Why wont this script work?

Asked by 8 years ago

I have been having issues with this script. This script just makes a dust particle when you touch the brick. (Yes I know that I'm not very good at scripting, but I'm still learning c;)

script.Parent.Touched:connect(function(Hit)
local x = Hit.Parent:FindFirstChild("Left Leg")
if x ~= nil then
local Dust = script.Dust
Dust:Clone()
game.Debris:AddItem(Dust, 3)
Dust.Parent = x
Dust.Enabled = true
wait(0.1)
Dust.Enabled = false



end
end)

0
It only works once. UltraUnitMode 419 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

It seems you're removing the only dust particle there is after 3 seconds. To make it so it's the clone of the dust we want to remove, we'd need to make a variable for it like:

Dust = script.Dust
Dust = Dust:Clone()  -- the clone of dust
game.Debris:AddItem(Dust, 3)

The final version:

script.Parent.Touched:connect(function(part)
    local hit = part.Parent:FindFirstChild("Left Leg")
    if hit then
        local Dust = script.Dust:Clone()
        Dust.Parent = hit
        game.Debris:AddItem(Dust, 3)
    end
end)
Ad

Answer this question