Sorry, I don’t have time to finish it right now, but this tutorial should help. I most likely did something wrong with the code though, but it should be fairly easy to fix.
Seems you’re using the CurrentBullet instance as a param for your bulletGoal CFrame. You can see in the logs it’s throwing an error as you’re trying to add it with the mousePosition. Would suggest replacing it with the bullet CFrame.Position.
wait()
local Weapon = script.Parent.Parent
local Sounds = Weapon:FindFirstChild("Sounds")
local Player = Weapon.Parent.Parent
local Events = Weapon:FindFirstChild("Events")
local Anims = Weapon:FindFirstChild("Animations")
local Config = Weapon.Configuration
local RS = game:GetService("ReplicatedStorage")
local Bullet = RS.Bullet
local TS = game:GetService("TweenService")
Events.Shoot.OnServerEvent:Connect(function(player, mousePosition)
print("Shoot event connected")
if Config.Ammo.Value > 0 then
Sounds.Shoot:Play()
Config.Ammo.Value -= 1
local CurrentBullet = Bullet:Clone()
CurrentBullet.Parent = workspace
CurrentBullet.Position = Weapon.Barrel.Position
CurrentBullet.Damage.Value = Config.Damage.Value
CurrentBullet.Player.Value = Player.Name
print("bullet made")
local BulletGoal = {}
BulletGoal.Position = CurrentBullet.CFrame.Position + mousePosition
BulletGoal.Velocity = 400
BulletGoal.Transparency = 0.5
BulletGoal.Color = Color3.new(1, 0.635294, 0)
print("Goal made")
local tweeninfo = TweenInfo.new()
local tween = TS:Create(CurrentBullet, tweeninfo, BulletGoal)
tween:Play()
print("Tween played")
wait(Config.Firerate.Value)
end
end)
Events.Reload.OnServerEvent:Connect(function()
if Config.Ammo.Value < Config.Magazine.Value then
Sounds.Reload:Play()
wait(Config.Reload.Value)
Config.Ammo.Value = Config.Magazine.Value
end
end)
but got : 17:38:05.318 TweenService:Create property named ‘Velocity’ cannot be tweened due to type mismatch (property is a ‘Vector3’, but given type is ‘double’) - Server - ServerHandler:40