I am working on a solution please give me around 5-10 minutes
I have figured out a way to make the orb constantly follow the player once they were in range but it seems to just stay behind the player and the player would have to stop in order for the player to collect it.
Code:
local ThisPart = script.Parent
local players = game:GetService("Players"):GetPlayers()
local pickedPlayer = players[math.random(1, #players)]
local alredytriggered = false
while wait() do
local PlrPosition = pickedPlayer.Character:FindFirstChild("HumanoidRootPart").Position
Distance = (ThisPart.Position - PlrPosition).Magnitude
if Distance < 20 or alredytriggered == true then
alredytriggered = true
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0,false,0)
local tween = TweenService:Create(ThisPart, tweenInfo, {Position = PlrPosition})
tween:Play()
wait()
tween:Cancel()
end
end
Torque and force along with cframes to smooth this out. Search a few pet videos. If it’s following you like a pet. The other script could move a bit fast when comming to the player.
I am struggling to find a video, do you mind helping me out?
Try This?
local ThisPart = script.Parent
ThisPart.Anchored = false
local Force = Instance.new("BodyPosition")
Force.Position = ThisPart.Position
Force.MaxForce = Vector3.new(3000,5000,3000)
Force.D = 1000
local players = game:GetService("Players"):GetPlayers()
local pickedPlayer = players[math.random(1, #players)]
local alredytriggered = false
while wait() do
local PlrPosition = pickedPlayer.Character:FindFirstChild("HumanoidRootPart").Position
Distance = (ThisPart.Position - PlrPosition).Magnitude
if Distance < 20 or alredytriggered == true then
alredytriggered = true
Force.Position = PlrPosition
end
end
Took me a bit to figure this out, because you set the orb to unanchored it falls through the floor. Should I just put that in the script when the distance is below 20?
I forgot to set the .Parent property.
local ThisPart = script.Parent
ThisPart.Anchored = false
local Force = Instance.new("BodyPosition")
Force.Position = ThisPart.Position
Force.MaxForce = Vector3.new(3000,5000,3000)
Force.D = 1000
Force.Parent = ThisPart
local players = game:GetService("Players"):GetPlayers()
local pickedPlayer = players[math.random(1, #players)]
local alredytriggered = false
while wait() do
local PlrPosition = pickedPlayer.Character:FindFirstChild("HumanoidRootPart").Position
Distance = (ThisPart.Position - PlrPosition).Magnitude
if Distance < 20 or alredytriggered == true then
alredytriggered = true
Force.Position = PlrPosition
end
end
Try it now
3 things:
-
When the orb is placed the orb teleports to a specific location again
-
The orb is WAY smoother than before so
-
The orb still does the chasing thing
local ThisPart = script.Parent
local can = true
local players = game:GetService("Players"):GetPlayers()
local pickedPlayer = players[math.random(1, #players)]
while wait() do
local PlrPosition = pickedPlayer.Character.PrimaryPart.Position
Distance = (ThisPart.Position - PlrPosition).Magnitude
if Distance < 10 and can == true then
can = false
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.In, 0,false,0)
local tween = TweenService:Create(ThisPart, tweenInfo, {Position = Vector3.new(PlrPosition.X, PlrPosition.Y, PlrPosition.Z)})
tween:Play()
end
end
But we don’t need that code anymore
I only changed the position so he can grab that chunk out. I should highlight it rq.
ThisPart.Anchored = true
wait(1)
local ThisPart = script.Parent
ThisPart.Anchored = false
local Force = Instance.new("BodyPosition")
Force.Position = ThisPart.Position
Force.MaxForce = Vector3.new(3000,5000,3000)
Force.D = 1000
Force.Parent = ThisPart
local players = game:GetService("Players"):GetPlayers()
local pickedPlayer = players[math.random(1, #players)]
local alredytriggered = false
while wait() do
local PlrPosition = pickedPlayer.Character:FindFirstChild("HumanoidRootPart").Position
Distance = (ThisPart.Position - PlrPosition).Magnitude
if Distance < 20 or alredytriggered == true then
alredytriggered = true
Force.Position = PlrPosition
end
end
{Position = Vector3.new(PlrPosition.X, PlrPosition.Y, PlrPosition.Z)})
Replace this for position. PlrPosition is a Vector3 and you can’t place a Vector3 within one part and leaving the rest blank.
That is just PlrPosition but unnecessary complicated so anyone who wants to edit the code has a stroke.
…
This should make sure its position is where it is created
GOOD NEWS!!!
-
The orb reacts when near it while also staying in place
-
The orb still can’t catch up with the player
Would you like a vid?
local Time = 1
local Orb = nil --Path orb
while task.wait() do
Orb.CFrame = Orb.CFrame:Lerp(PlrPosition, Time)
end
Try lerping.
Not too familiar with it so do some trial/error runs.
ThisPart.Anchored = true
wait(1)
local ThisPart = script.Parent
ThisPart.Anchored = false
local Force = Instance.new("BodyPosition")
Force.Position = ThisPart.Position
Force.MaxForce = Vector3.new(3000,5000,3000)
Force.D = 1000
Force.Parent = ThisPart
Force.P = 20 --Change this to whatever the speed is?
local players = game:GetService("Players"):GetPlayers()
local pickedPlayer = players[math.random(1, #players)]
local alredytriggered = false
while wait() do
local PlrPosition = pickedPlayer.Character:FindFirstChild("HumanoidRootPart").Position
Distance = (ThisPart.Position - PlrPosition).Magnitude
if Distance < 20 or alredytriggered == true then
alredytriggered = true
Force.Position = PlrPosition
end
end
Referring back to this code, you could increase the force of the orb to make it go faster.
Never used BodyPosition before so whichever controls the speed.
Also yeah, a video would be cool if that’s necessary.
So increasing the force did not do anything but here is the video
(post deleted by author)
not really