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

Why isn't the position being set?

Asked by 6 years ago
Edited 6 years ago

So im trying to make a gun to my game, and it is working fine but when it came to the point to make the bullet appear and set it's position its wont work. Also i want to set its orientation to the mouse position, and also stop it at the closest object.

This is my script:

01local pistola = script.Parent
02local hole = game.StarterPack.Pistola.Hole
03local mouse = game.Players.LocalPlayer:GetMouse()
04 
05-- Lista de Valores --
06local ammo = 12
07local maxAmmo = 64
08local damage = 20
09local headshotDamage = 50
10local range = 100
11-- impedir spamming --
12local spam = false
13 
14    -- Disparo --
15    pistola.Activated:Connect(function()
View all 30 lines...

So here's a summary of my questions: 1: Why isn't the position being set; 2: How can i get the position of the mouse; 3:How can i set the bullet size to stop when it hits something, like a wall or a player?

Thank you for helping me (if you did helped me XD) Also im using a local script, if you need to know...

0
Also this is the second time i post this, cuz the first time i waited for 5 days and got no answer so, yeah. XD mewant_taco 17 — 6y
0
You know you can ray cast right User#19524 175 — 6y
0
local ray = Ray.new(hole.CFrame.Position, (mouse.Hit.Position - hole.CFrame.Position).Unit*number) User#19524 175 — 6y
0
still doesn't work ;-; mewant_taco 17 — 6y
View all comments (2 more)
0
duh, bc thats only a part of raycasting, you need to use :FindPartOnRay() User#23365 30 — 6y
0
oh ok, could you send me a fix? im bad at scripting sry mewant_taco 17 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

The position is represented by CFrame.

1Bullet.CFrame =  hole.CFrame
0
it didn't worked ;-; mewant_taco 17 — 6y
Ad

Answer this question