-
What do you want to achieve? I want a part to only pull a localplayer, when stepping on a part.
-
What is the issue? I don’t seem to know how I can make those types of functions and how I can continue
-
What solutions have you tried so far? My first thoughts is that I’ll need magnitude.
I assume by this you mean you only want to pull one player. This can be acheived pretty easily by using a BodyPosition inserted via a script into the torso of the player. Set the position for the BodyPosition to the position of the black hole and it should work. Let me know if you need more details on how to achieve this exactly.
Put a BodyPosition
in the localplayer character’s primarypart.
local bp = Instance.new("BodyPosition", Character.PrimaryPart)
bp.Position = Blackhole.Position
bp.D = 1000 -- Adjust to your liking.
bp.MaxForce = Vector3.new(10000, 10000, 10000) -- Adjust to your liking
bp.P = 1000 -- Adjust to your liking
Remove it when you want it stop pulling.
I’ll edit the first question, since I should have said that earlier.
Is this just a regular part name?
Blackhole
should be a reference to the part which you want the player to be pulled towards.
Try using lineforces you can use the InverseSquareLaw property
Sorry for questioning again I hope I won’t annoy you: Where does this script go exactly? I tried putting it in StarterPlayer and StarterCharacterScripts and didn’t fit.
This isn’t a complete script. Perhaps telling us when you want the person to be pulled to the black hole would be useful so we can help you know where to put it. Is there a part or something that they need to step on?
Yes. Let’s say you step into a part and there’s the “black hole” pulling you when you step on the part (After you step into the black hole you get teleported).
CAn you make a blackhole using lineforces
I think you can, since I just watched a tutorial about lineforces. For me it would be a bit too difficult using that, not sure why I would think off that.
I will try to make a blackhole using lineforces ill come back
Line forces would actually be a pretty good approach for this
A lot of the times theyre used in planetary stuff and theyre nice to set up
Basically all you need is:
Part0 -|
Attachment0
Part1 -|
Attachment1
LineForce
After you make that hierarchy you just need to set the LineForce’s attachment0 and 1 properties to the correct attachments and mess around with the force
Probably this
local Blackhole = script.Parent
local function findTarget()
local PullDistance = 7500 – Gravity
local target = nil
for i,v in pairs(game.Workspace:GetChildren()) do
local human = v:FindFirstChild(“Humanoid”)
if human and v ~= script.Parent then
– Check distance
if (MonsterTorso.Position - torso.Position).magnitude < agroDistance then
agroDistance = (MonsterTorso.Position - torso.Position).magnitude
target = torso
human:MoveTo(script.Parent.Position)
human.WalkSpeed = 4000 – To make it look like your being pulled in.
end
end
end
return target
end
Hi! Sorry, I was done for the night.
Did you use a LocalScript in StarterPlayerScripts?
-- Localscript
local LocalPlayer = game.Players.LocalPlayer -- The local player.
local TeleportService = game:GetService("TeleportService")
repeat wait() until LocalPlayer and LocalPlayer:HasAppearanceLoaded() -- Waiting for the character to fully load to avoid "this part doesn't exist errors".
local Char = LocalPlayer.Character
local BlackholePart = --Reference the part in the middle of the blackhole.
local ActivationPart = --Reference the part that you step on to activate the blackhole.
local BlackholeActive = false -- Debounce
ActivationPart.Touched:Connect(function()
if BlackHoleActive then return end -- Debounce
BlackholeActive = true
local bp = Instance.new("BodyPosition", Character.HumanoidRootPart)
bp.Position = BlackholePart.Position
bp.D = 1000 -- Adjust to your liking.
bp.MaxForce = Vector3.new(10000, 10000, 10000) -- Adjust to your liking
bp.P = 1000 -- Adjust to your liking
repeat wait(1) until (BlackholePart.Position - Char.HumanoidRootPart.Position).Magnitude < 2 -- Waits until the player is close enough to the center of the blackhole.
TeleportService:Teleport(PlaceIdToTeleportTo) -- Teleports the player.
end)
It should look like this.
This is the script I searched for, but I meant a part that teleports to the part. I should have said that earlier. Very sorry.
TeleportService:Teleport(PlaceIdToTeleportTo) -- Teleports the player.
to
Char.HumanoidRootPart.CFrame = PartThatThePlayerTeleportsTo.CFrame
Is this what you mean?
If that’s similar to 2 teleport pads that teleport you, then yes. I’ll edit the comment if something changed or worked.
Edit: Must be the script like this?
local LocalPlayer = game.Players.LocalPlayer -- The local player.
local TeleportService = game:GetService("TeleportService")
repeat wait() until LocalPlayer and LocalPlayer:HasAppearanceLoaded() -- Waiting for the character to fully load to avoid "this part doesn't exist errors".
local Char = LocalPlayer.Character
local BlackholePart = game.Workspace.TheHole --Reference the part in the middle of the blackhole.
local ActivationPart = game.Workspace.TheActive --Reference the part that you step on to activate the blackhole.
local BlackholeActive = false -- Debounce
ActivationPart.Touched:Connect(function()
if BlackHoleActive then return end -- Debounce
BlackholeActive = true
local bp = Instance.new("BodyPosition", Character.HumanoidRootPart)
bp.Position = BlackholePart.Position
bp.D = 1000 -- Adjust to your liking.
bp.MaxForce = Vector3.new(10000, 10000, 10000) -- Adjust to your liking
bp.P = 1000 -- Adjust to your liking
repeat wait(1) until (BlackholePart.Position - Char.HumanoidRootPart.Position).Magnitude < 2 -- Waits until the player is close enough to the center of the blackhole.
Char.HumanoidRootPart.CFrame = PartThatThePlayerTeleportsTo.CFrame -- Teleports the player.
end)
Yea, but don’t forget this line
Char.HumanoidRootPart.CFrame = **PartThatThePlayerTeleportsTo**.CFrame -- Teleports the player.`
If there are any errors, I can take a look if you point me the line and the error message.