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

Why wont my Body Position script work?

Asked by
neoG457 315 Moderation Voter
8 years ago
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

enabled = true
Mouse.KeyDown:connect(function(key)
if not enabled then
        return
    end
if key == "z" then

       --make and do a hit test along the ray
       local ray = Ray.new(Player.Character.Torso.CFrame.p, (Mouse.Hit.p - Player.Character.Torso.CFrame.p).unit*300)
       local hit, position = game.Workspace:FindPartOnRay(ray, Player)



local distance = (position - Player.Character.Torso.CFrame.p).magnitude
        local rayPart = Instance.new("Part", workspace)
        rayPart.Name          = "RayPart"
        rayPart.BrickColor    = BrickColor.new("Bright red")
        rayPart.Transparency  = 0
        rayPart.Anchored      = false
        rayPart.CanCollide    = true
        rayPart.TopSurface    = Enum.SurfaceType.Smooth
        rayPart.BottomSurface = Enum.SurfaceType.Smooth
        rayPart.formFactor    = Enum.FormFactor.Custom
        rayPart.Size          = Vector3.new(5, 5, 5)
        rayPart.CFrame        = CFrame.new(position, Player.Character.Torso.CFrame.p) * CFrame.new(0, 0, 0)

local Woosh = Instance.new("BodyPosition")
Woosh.maxForce = Vector3.new(math.huge, math.huge, math.huge)
Woosh.position = Vector3.new(0, 0, distance)
Woosh.Parent = rayPart
end
end) 

This script is meant to fire the rayPart from my torso and to where my mouse is pointing whenever I press Z. However it fires from where ever my mouse is pointing to a random position instead. Please Fix This For Me.

0
IM HAVING A HUGE TROUBLE WITH BODY POSITIONS TODAY TOO! I think i have to put in the exact weight, * the size, which to do that is: script.Parent:GetMass() * (script.Parent.Size.X *script.Parent.Size.Y*script.Parent.Size.Z) < thats what the maxForce should be. deputychicken 226 — 8y

Answer this question