So, I am lurking about to try and improve my understanding of lua a bit more and decided ‘hey, why not make a gun?’ (worst mistake of my life).
So far, what is working is:
- When the tool is activated, it is able to make a noise
What isn’t working:
- No bullet is cloned (apparently)
- No errors occur
Sorry if the script is a bit messy, I’ve been on a big hiatus while I focused on exams and have only recently moved back into developing on Roblox.
local gun = script.Parent
local ServerStorage = game:GetService("ServerStorage")
local tool = script.Parent.Parent
local shot = gun.GunShot
local dist = 200
local count = 0
local function onClick()
local bullet = ServerStorage.Bullet:Clone()
local bulletpos = bullet.Position
bulletpos = Vector3.new(gun.Position)
shot.TimePosition = 0
shot.Playing = true
wait(shot.TimeLength)
while dist > count do
bulletpos = Vector3.new(bulletpos.X+1,bulletpos.Y,bulletpos.Z)
count = count + 1
end
bullet:Destroy()
end
tool.Activated:Connect(onClick)
Note: I haven’t followed any one tutorial, and have mostly went off browsing the dev forum and reading documentation.
(If you’re wondering why it only goes in the X axis, I’m trying to get it to fire a projectile, not fire at the mouse direction, for now)