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

I need help with ClickDetector in my part PetClick ?

Asked by 4 years ago
Edited 4 years ago

I have part named PetClick I want if player click on the part the pet follow them and I want also delete PetClick part if i click on part the pet follow player but the part dont delete this is my script

local pet = script.Parent

function givePet (player)
    if player then
        local character = player.Character
        if character then
            local humRootPart = character.HumanoidRootPart
            local newPet = pet:Clone()
            newPet.Parent = character

            local bodyPos = Instance.new("BodyPosition", newPet)
            bodyPos.MaxForce = Vector3.new(math.huge, math.huge, math.huge)

            local bodyGyro = Instance.new("BodyGyro", newPet)
            bodyGyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)



            while wait() do
                bodyPos.Position = humRootPart.Position + Vector3.new(2, 2, 3)
                bodyGyro.CFrame = humRootPart.CFrame


            end
        end
    end
end
local PetClick = game.Workspace.PetClick
game.Workspace.PetClick.ClickDetector.MouseClick:Connect(function(player) 
    givePet(player) and PetClick:Destroy()
    end)
0
Line 30, you shouldn't use the "and" and call the functions from seperate lines marijus06 68 — 4y
0
what i can use MONSTERGAMES3609 14 — 4y
0
Replace the 30 line with givePet(Player) and add another line and write PetClick:Destroy() marijus06 68 — 4y
0
dont work the part dont destroy the pet follow me only but the part dont destroy MONSTERGAMES3609 14 — 4y
View all comments (4 more)
0
can you vote to my question MONSTERGAMES3609 14 — 4y
0
Then you should try destroying the part first and then calling the give pet function marijus06 68 — 4y
0
thank you sooooooooooooooooooooooooo much thank you MONSTERGAMES3609 14 — 4y
0
put your answer in answers to make it correct answer thank you so much i try to make this for months thank you you are the best thank you sooooooo much MONSTERGAMES3609 14 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Replace the 30 line with givePet(Player) and add another line and write PetClick:Destroy() Then you should try destroying the part first and then calling the give pet function Answers by marijus06

Ad

Answer this question