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

Cone gives multiple cones when clicked?

Asked by 6 years ago
Edited 6 years ago

I have a cone giving script but every time I click on the cone it gives me atleast 4 cones instead of one. HELP here is the script -- ALSO, THE ANIMATION DOESNT PLAY SO WHEN THE CONE IS EQUIPPED AND SOMEONE CLICKS, IT DOESNT PLAY THE EATING ANIMATION HELPPP

["ConeGiver"] = function(Machine)
        local Touch = Machine.Touch
        if Touch:FindFirstChildOfClass("ClickDetector") then
            Touch.ClickDetector.MouseClick:Connect(function(Player)
                local Sound = Touch:FindFirstChildOfClass("Sound")
                if Sound then
                    Sound:Stop()
                    wait()
                    Sound:Play()
                end
                local Cone = Machine.Cone:Clone()
                local Tool = Instance.new("Tool",Player.Backpack)
                Tool.Name = "Cone"
                Tool.CanBeDropped = false
                local Handle = Cone:WaitForChild("Handle")
                for _,Part in pairs(Cone:GetChildren()) do
                    if Part.Name ~= "Handle" then
                        local Weld = Instance.new("Weld",Part)
                        Weld.Part0 = Part
                        Weld.Part1 = Handle
                        Weld.C0 = Part.CFrame:inverse()
                        Weld.C1 = Handle.CFrame:inverse()
                        wait()
                    end
                    Part.Anchored = false
                    Part.Parent = Tool
                    wait()
                end
                local DrinkScript = script:WaitForChild("Drink"):Clone()
                DrinkScript.Parent = Tool
                DrinkScript.Disabled = false
            end)
        end
    end,
}
0
You might be connecting multiple MouseClick events to the same click detector? User#5423 17 — 6y

Answer this question