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
01 | local pet = script.Parent |
03 | function givePet (player) |
05 | local character = player.Character |
07 | local humRootPart = character.HumanoidRootPart |
08 | local newPet = pet:Clone() |
09 | newPet.Parent = character |
11 | local bodyPos = Instance.new( "BodyPosition" , newPet) |
12 | bodyPos.MaxForce = Vector 3. new( math.huge , math.huge , math.huge ) |
14 | local bodyGyro = Instance.new( "BodyGyro" , newPet) |
15 | bodyGyro.MaxTorque = Vector 3. new( math.huge , math.huge , math.huge ) |
20 | bodyPos.Position = humRootPart.Position + Vector 3. new( 2 , 2 , 3 ) |
21 | bodyGyro.CFrame = humRootPart.CFrame |
28 | local PetClick = game.Workspace.PetClick |
29 | game.Workspace.PetClick.ClickDetector.MouseClick:Connect( function (player) |
30 | givePet(player) and PetClick:Destroy() |