You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
the position of pet is same position as RightGripAttachment
What is the issue? Include screenshots / videos if possible!
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
A lot
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Your pet has same position as RightGripAttachment, and what is wrong? It is same because YOU LITERALLY SET IT TO THE RIGHTGRIPATTACHMENTS WORLD CFRAME.
Please tell more details about what you want, what is the problem.
Maybe if you wanted the smooth movement of pet, you can decrease alpha value of Lerp function to like 0.1 or 0.3.
I set it world cframe since if i put normal cframe it would go to 0,0,0. And the problem is that it doesnt go to RightGripAttachment, it goes behind the rightgrip attachment
It seems like you have another script that sets the pet’s CFrame/Position to behind the Head’s Position.
And you want the pet’s position to be on rightGripAttachment’s position when using that skill? ( idk if thats skill )
If that is correct, I think you should put if statement to the script that sets pet’s position behind the head.
( I will call the script that sets the position of pet to the RightGripAttachment “Script1” )
( And I will call the script that sets the position of pet to behind of the head “Script2” )
I think you use while loop in Script2 i think, and because script2 is doing a loop, When script1 changes the position of pet to RightGripAttachment, Script2’s loop overrides and sets the position to behind the head, and this makes the pet’s position very glitchy. ( because pet’s position is constantly changing from head to RightGripAttachment ).
So as I said before, you should put if statement on Script2.
Example code
local function setPositionBehindHead()
pet.CFrame = character.Head.CFrame * CFrame.new(2,0,2)
end
while task.wait() do
if not usingSkill then
setPositionBehindHead()
end
end
Here’s whole script, i know i could optimize it but im too lazy
local pet = script.Parent
local rE = game.ReplicatedStorage.RemoteEvents
local Throw = false
local H = false
local C = false
local G = false
function givepet(player)
if player then
local character = player.character
if character then
local humanrootpart = character.HumanoidRootPart
local newpet = pet:Clone()
newpet.Parent = character
local bodyVel = newpet.BodyVelocity
rE.Throw.OnServerEvent:Connect(function(player)
if Throw == false then
if script.Parent.Action.Value == false then
script.Parent.Action.Value = true
Throw = true
local anim = script:WaitForChild("Animation")
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local loadanim = humanoid:LoadAnimation(anim)
wait()
bodyVel.Velocity = Vector3.new(0,0,0)
humanrootpart.Anchored = true
pet.CFrame = character:WaitForChild("Right Arm").RightGripAttachment.WorldCFrame
task.wait(1)
loadanim:play()
H = true
script.Parent.AnimPlaying.Value = true
loadanim.Stopped:Wait()
H = false
G = true
script.Parent.AnimPlaying.Value = false
humanrootpart.Anchored = false
wait()
bodyVel.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bodyVel.Velocity = humanrootpart.CFrame.lookVector * 40
task.wait(0.5)
bodyVel.Velocity = Vector3.new(0,0,0)
task.wait(0.5)
G = false
script.Parent.Action.Value = false
task.wait(2)
Throw = false
end
end
end)
local breaks = false
while breaks == false do
if script.Parent.Action.Value == false then
pet.CFrame = character:WaitForChild("HumanoidRootPart").CFrame * CFrame.new(3,2,2)
end
if H then
pet.CFrame = character:WaitForChild("Right Arm").RightGripAttachment.WorldCFrame
end
if G then
print("G")
pet.CFrame = pet.CFrame * CFrame.Angles(-1,0,0)
end
if character:WaitForChild("Humanoid").Health == 0 then
wait(7)
givepet(player)
pet:Destroy()
breaks = true
end
wait()
end
end
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local hum = char:WaitForChild("Humanoid")
givepet(player)
end)
end)