I fire an event and pass in the player’s mouse.Hit
as an argument, but then when i use the mouse parameter in the function, it’s the position that the mouse was at the moment the event was fired, I’m wondering how I’d get the actual/updated mouse position
while wait(0.1) and game.Workspace:FindFirstChild(plr.Name.." Auto Cannon") do
local x = math.random(-300, 300)/100
local y = math.random(-300, 300)/100
local bullet = meshes["Auto Cannon"].Bullet:Clone()
bullet.CFrame = CFrame.new(hrp.Position, mouse.p) * CFrame.new(x, y, -7)
bullet.Parent = effects
DS:AddItem(bullet, 0.7)
local ring = meshes["Auto Cannon"].Ring:Clone()
ring.CFrame = bullet.CFrame
ring.Parent = bullet
local wc = Instance.new("WeldConstraint", bullet)
wc.Part0 = bullet
wc.Part1 = ring
local tweenBullet = coroutine.create(function()
wait()
TS:Create(bullet, TweenInfo.new(0.5), {CFrame = CFrame.new(hrp.Position, mouse.p) * CFrame.new(x, y, -50)}):Play()
wait(0.5)
TS:Create(bullet, TweenInfo.new(0.2), {Size = bullet.Size + Vector3.new(5, 5, 0), Transparency = 1}):Play()
TS:Create(ring, TweenInfo.new(0.2), {Size = ring.Size + Vector3.new(5, 5, 0), Transparency = 1}):Play()
end)
coroutine.resume(tweenBullet)
end
Bullets go to where your mouse was when the event is fired, is there a way to update the mouse position so the bullets will go to that updated pos?