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

How can I make this new instance spawn at desired location?

Asked by 8 years ago

So, I pushed on in a script I was making earlier, and this time I have a real allocated question- Whenever I press E the new instance spawns a specific location diagonal of me. The script is supposed to create a new object at the torso that shoots out to mouse location. I posted this script in bareminimum earlier when I had no idea what I was doing- now I don't know why the location isn't where I specify through CFrame.

local tool = script.Parent
local player = game.Players.LocalPlayer
oh = player.Character.Torso.Position

tool.Equipped:connect(function(mouse)
game:GetService("UserInputService").InputBegan:connect(function(inputObject,
gameProcessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.E then
local blhl = Instance.new("Part", workspace)
    blhl.Name = "blhl"
    blhl.CFrame = CFrame.new(oh)
    blhl.Shape = 0
    blhl.BrickColor = BrickColor.new(1003)
    blhl.CanCollide = false
for i = 1, 5, .5 do
    blhl.Size = Vector3.new(i)
    blhl.CFrame = CFrame.new(oh)
local bp = Instance.new("BodyPosition", blhl)
    bp.Position = Vector3.new(mouse.Hit.x,mouse.Hit.y,mouse.Hit.z)
    bp.MaxForce = Vector3.new(10000, 10000, 10000)
    bp.D = 30000
    bp.P = 100000
end
end
end)
end)

Answer this question