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

Finding first child problem with Local Character?

Asked by 6 years ago
local player = game.Players.LocalPlayer


script.Parent.MouseButton1Down:connect(function()

    if player.ShopItems.Superfast.Value == 'true' and script.Parent.Text == 'Equip' and player.ShopItems.ParticleEquipped.Value ~= 'Superfast' then
        local Left player.Character.LeftFoot:FindFirstChild('ParticleL')
        while true do
        Left:Destroy()
        end
        local Right player.Character.RightFoot:FindFirstChild('ParticleR')
        while true do
        Right:Destroy()
        end
        local Sparkles1 = game.ReplicatedStorage.Superfast
        local clone1 = Sparkles1:Clone()
        clone1.Name = 'ParticleL'
        clone1.Parent = player.Character.LeftFoot
        local clone2 = Sparkles1:Clone()
        clone2.Name = 'ParticleR'
        clone2.Parent = player.Character.RightFoot
        player.ShopItems.ParticleEquipped.Value = 'Superfast' 
    elseif player.Coins.Value >= 100 and player.ShopItems.Superfast.Value == 'false' then
        script.Parent.Text = 'Purchase successful'
        script.parent.BackgroundColor3 = Color3.fromRGB(69, 255, 112)
        script.Parent.AutoButtonColor = false
        wait(1)
        script.Parent.Text = 'Equip'
        player.ShopItems.Superfast.Value = 'true' 
        script.Parent.BackgroundColor3 = Color3.fromRGB(255,255,255)
        script.Parent.AutoButtonColor = true
    else
        script.Parent.Text = 'OOF not enough coins'
        script.Parent.AutoButtonColor = false
        script.Parent.BackgroundColor3 = Color3.fromRGB(254, 69, 69)
        wait(1)
        script.Parent.BackgroundColor3 = Color3.fromRGB(255,255,255)
        script.Parent.Text = 'Buy for 100 Coins'
        script.Parent.AutoButtonColor = true


    end
end)

Some stuff no listed is that a sparkle particle emitter is placed into the right and left foot of the local player.

Players.legoch12.PlayerGui.Shop.Shop1.Superfast.Buy:9: attempt to index local 'Left' (a nil value) 

The error I get is above.

What I'm trying to do is make it so it finds the particle emitter in the foot of the player and then destroys it. If possible I would also like to add in a while loop that if it finds one and deletes it it keeps looking to see if there is another one which also stumps me

0
Found the problem! Thanks for viewing legoch12 45 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
local player = game.Players.LocalPlayer


script.Parent.MouseButton1Down:connect(function()

    if player.ShopItems.Superfast.Value == 'true' and script.Parent.Text == 'Equip' and player.ShopItems.ParticleEquipped.Value ~= 'Superfast' then
        local Left player.Character.LeftFoot:FindFirstChild('ParticleL'):Destroy()
        local Right player.Character.RightFoot:FindFirstChild('ParticleR'):Destroy()
        local Sparkles1 = game.ReplicatedStorage.Superfast
        local clone1 = Sparkles1:Clone()
        clone1.Name = 'ParticleL'
        clone1.Parent = player.Character.LeftFoot
        local clone2 = Sparkles1:Clone()
        clone2.Name = 'ParticleR'
        clone2.Parent = player.Character.RightFoot
        player.ShopItems.ParticleEquipped.Value = 'Superfast' 
    elseif player.Coins.Value >= 100 and player.ShopItems.Superfast.Value == 'false' then
        script.Parent.Text = 'Purchase successful'
        script.parent.BackgroundColor3 = Color3.fromRGB(69, 255, 112)
        script.Parent.AutoButtonColor = false
        wait(1)
        script.Parent.Text = 'Equip'
        player.ShopItems.Superfast.Value = 'true' 
        script.Parent.BackgroundColor3 = Color3.fromRGB(255,255,255)
        script.Parent.AutoButtonColor = true
    else
        script.Parent.Text = 'OOF not enough coins'
        script.Parent.AutoButtonColor = false
        script.Parent.BackgroundColor3 = Color3.fromRGB(254, 69, 69)
        wait(1)
        script.Parent.BackgroundColor3 = Color3.fromRGB(255,255,255)
        script.Parent.Text = 'Buy for 100 Coins'
        script.Parent.AutoButtonColor = true


    end
end)

Solution for anyone looking

Ad

Answer this question