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

Body Position objects are not working in the gun script, any help?

Asked by 5 years ago

The code doesn't work when it tries to put in a vector3 value, though I don't know why. Client Script

script.Parent.Equipped:Connect(function(Mouse)
    script.Parent.Activated:Connect(function()
        local MousePos = Mouse.Hit.p
        game.ReplicatedStorage.RemoteEvent:FireServer(MousePos, script.Parent.Handle.position)
    end)
end)

server script

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(Plr,MousePos,GunPos)
    local CloneBullet = game.ServerStorage.Bullet:Clone()
    print(MousePos)
    CloneBullet.Position = GunPos
    CloneBullet.BodyPosition.Position = Vector3.new(MousePos)
    CloneBullet.Parent = game.Workspace
end)

The bullet is just a sphere with a body position object in it.

1 answer

Log in to vote
0
Answered by 5 years ago

My answer is that I found an error with the "Vector3.new", because the script doesn't know what the X,Y and Z is.

Instead of just putting "MousePos", try

CloneBullet.BodyPosition.Position = Vector3.new(MousePos.X,MousePos.Y,MousePos.)

so the script understands where to go with your mouse.

(note: i am not that much of a scripter but I attempted to see the problem and pictured how to fix it)

0
mouse.Hit.Position returns the x,y and z position of it, so its pointless User#23365 30 — 5y
0
ok man, you can just negatively comment but it's not gonna help anyone. speedyfox66 237 — 4y
Ad

Answer this question