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

Body Position positioning me to somewhere random?

Asked by 4 years ago
Edited 4 years ago

I do not know the issue. But whenever the BP is used it just positions me to somewhere random? Its supposed to be a jump, and holds the player in air while a projectile fires. (A jump kind of effect into the air) I don't know the problem, but I have attached my script to this thread. Please help!

01-- Variables
02local UIS = game:GetService("UserInputService")
03local Cam = script:WaitForChild("CamShake")
04local ButtonEvent = script:WaitForChild("BtnDown")
05local plr = game.Players.LocalPlayer
06local Mouse = plr:GetMouse()
07local Debounce = true
08local BtnDown = false
09Player = game.Players.LocalPlayer
10Char = Player.Character
11 
12--- Functions:
13local Tool = script.Parent
14 
15Tool.Equipped:Connect(function()
View all 90 lines...
0
do you need to teleport or take a player somewhere? panvvan 20 — 4y
0
I was unable to replicate the issue (I was seizuring in place instead). Could something else be affecting the position of the player? Sparks 534 — 4y

2 answers

Log in to vote
2
Answered by
Sparks 534 Moderation Voter
4 years ago
Edited 4 years ago

I used to use BodyPositions to hold the player in place while firing a move. When I tried your properties, they kind of flung me all over the place. I suggest using a combination of BodyPosition and BodyGyro to help stabilize the player.

01local BG = Instance.new("BodyGyro")
02BG.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
03BG.P = 8500
04BG.D = 500
05BG.Parent = Char.HumanoidRootPart
06BG.CFrame = CFrame.new(Char.HumanoidRootPart.Position, Mouse.Hit.Position)
07 
08local BP = Instance.new("BodyPosition")
09BP.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
10BP.P = 15000
11BP.D = 1250
12BP.Position = Char.HumanoidRootPart.Position
13BP.Parent = Char.HumanoidRootPart

Your issue could be with changing the properties after parenting, which could lead to the BodyPosition's default properties going into play on the physics engine before you set the new ones.

If you have charging or delayed attacks, make sure to update the Gyro's CFrame to the new mouse position every frame.

0
Yeah I do charging. And I have the bodygyro thingy. It's just the BP that keeps messing the move up. XxWingKing 96 — 4y
0
Also, this didn't work. It just didn't do anything XxWingKing 96 — 4y
0
I just tested it and it works. Could something else in your code prevent it from working? Sparks 534 — 4y
0
If you need to force the player to jump then the BP position needs to be Char.HumanoidRootPart.Position + Vector3.new(0, JUMPHEIGHTHERE, 0) Sparks 534 — 4y
View all comments (7 more)
0
Would you want me to edit it and show you? XxWingKing 96 — 4y
0
Yes, it would help a lot if you could show a bit more. Have you checked to see if your code reaches the BodyPosition part? You should check the explorer when Playing Solo to see if the BodyPosition was made at all. Sparks 534 — 4y
0
Did you end up figuring out the problem? You upvoted my answer so I am not sure if that means you fixed it or not. Sparks 534 — 4y
0
The BP is being made. (And the gyro works). I edited the thread please re-read it. XxWingKing 96 — 4y
0
I again tried your code for your first UIS.InputBegan connection and the BodyPosition and BodyGyro work as expected. Sparks 534 — 4y
0
Whats your discord? I'll give you the full server script. XxWingKing 96 — 4y
0
My Discord is Zatara#0001. However, when I tried putting the LocalScript in a tool, I got an error saying "attempted to index HumanoidRootPart with nil." Did you get this error as well in the output? Sparks 534 — 4y
Ad
Log in to vote
1
Answered by
panvvan 20
4 years ago
Edited 4 years ago

u didnt rlly explain why u need to use this so i assume you would want to teleport a player somewhere so u can simply make a part where u want to teleport them make it invisible and and can collide of and use this (I EDITED THE ANS)

1Char.HumanoidRootPart.CFrame = Char.Head.CFrame + Vector3.New(0, 5, 0)

this should teleport the player slightly above their head then u can anchor the player or whatever u want to keep it in air the unanchoore the player to get it back down

0
It will be appreciated if this solves your problem and dont forget to accept this ans panvvan 20 — 4y
0
Its supposed to be a jump, and holds the player in air while a projectile fires. (A jump kind of effect into the air) XxWingKing 96 — 4y
0
ok so make the humanoid root part go above the head panvvan 20 — 4y

Answer this question