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

My gun script asks for a vector when it's a cframe?

Asked by 6 years ago

I'm trying to make a fe gun but when I try to cframe it this happens script.

game.ReplicatedStorage.Shoot.OnServerEvent:connect(function(player, position)
    local s = require(game.ReplicatedStorage.GunData.FAMAS)
    if workspace[player.Name].Humanoid.Health <=0 then
    else
--      local distance = (workspace.CurrentCamera.FAMAS.FAMAS.Flash.CFrame.p - position).magnitude
        local bullet = Instance.new("Part", workspace.Bullets)
        bullet.CFrame = CFrame.new(workspace.CurrentCamera.FAMAS.FAMAS.Flash.CFrame.p, position) * CFrame.new(0,0,-s.range/2)
        bullet.BrickColor = BrickColor.new("New Yeller")
        bullet.Size = Vector3.new(0.2,0.2,0.2)
        bullet.Material = "Neon"
        bullet.Name = "Bullet"
        bullet.Anchored = false
        bullet.CanCollide = false
        bullet.Locked = true
    end
end)

Error

12:41:11.085 - ServerScriptService.Event:7: bad argument #2 to 'new' (Vector3 expected, got Object)

Can someone help :()

0
What type does  the variable "position" hold? User#5423 17 — 6y
0
line 7, change cframe to vector greatneil80 2647 — 6y
0
Try doing vector3.new instead of CFrame.new Noahster3501 -2 — 6y
0
yea i did that but then another error came in i forgot what it was my pc died sorry. GameBoyOtaku 63 — 6y
View all comments (3 more)
0
and the position thing i actually don't know i was using a tutorial on youtube by Alvin Blox but i want my bullet to have velocity and realism but of course it doesn't work. GameBoyOtaku 63 — 6y
0
Whats the variable "position" actually hold??????? abnotaddable 920 — 6y
0
well i don't remember defining the variable because this is the server script side . I don't know what to do i'm lost, GameBoyOtaku 63 — 6y

Answer this question