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

i am trying to make an gun thou the bullets go side ways how do i fix?

Asked by 5 years ago

the script

local cahr = game.Players.LocalPlayer.Character
local mouse = game.Players.LocalPlayer:GetMouse()

script.Parent.Activated:Connect(function()
    local x = Instance.new("Part",workspace)
    local bv = Instance.new("BodyVelocity",x)
    x.Size = Vector3.new(0.48, 0.14, 0.15)
    x.BrickColor = BrickColor.new("Bright yellow")
    x.Material = "Neon"
    x.Position = script.Parent.Handle.shot.Position
    x.Orientation = script.Parent.Handle.shot.Orientation.Y

end)


script.Parent.Deactivated:Connect(function()

end)

2 answers

Log in to vote
0
Answered by
jaschutte 324 Moderation Voter
5 years ago

I don't fully understand your question, but I think this fixes it:

local cahr = game.Players.LocalPlayer.Character
local mouse = game.Players.LocalPlayer:GetMouse()
local power = 100 --the power of the bullet

script.Parent.Activated:Connect(function()
    local x = Instance.new("Part",workspace)
    local bv = Instance.new("BodyVelocity",x)
    x.Size = Vector3.new(0.48, 0.14, 0.15)
    x.BrickColor = BrickColor.new("Bright yellow")
    x.Material = "Neon"
    x.Position = script.Parent.Handle.shot.Position
    x.Orientation = Vector3.new(0,script.Parent.Handle.shot.Orientation.Y,0)
    bv.Velocity = x.LookVector * power
end)


script.Parent.Deactivated:Connect(function()

end)
0
Pellm did that already. jaschutte 324 — 5y
Ad
Log in to vote
0
Answered by
piRadians 297 Moderation Voter
5 years ago

Do not use the second argument of Instance.new() it is deprecated, and shouldn't be used. Also you set the orientation which holds 3 values, to only one, the Y value. Don't do that unless you will set only the Y axis.

local cahr = game.Players.LocalPlayer.Character
local mouse = game.Players.LocalPlayer:GetMouse()
local power = 100 --the power of the bullet

script.Parent.Activated:Connect(function()
    local x = Instance.new("Part")
x.Parent = workspace    
    local bv = Instance.new("BodyVelocity")
bv.Parent = x 
    x.Size = Vector3.new(0.48, 0.14, 0.15)
    x.BrickColor = BrickColor.new("Bright yellow")
    x.Material = "Neon"
    x.Position = script.Parent.Handle.shot.Position
    x.Orientation = Vector3.new(0,script.Parent.Handle.shot.Orientation.Y,0)
    bv.Velocity = x.LookVector * power
end)


script.Parent.Deactivated:Connect(function()

end)

Answer this question