Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

1 comment

0

Pellm did that already.

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.