I made a gun and I want the bullet to tween to the plater's mouse position everytimes the player clicks, but instead it just tween to the spawn location whereever my mouse is. Here's the localscript in the tool:
local player = game.Players.LocalPlayer
local Mouse = player:GetMouse()
local debounce = false
Mouse.Button1Down:Connect(function()
if debounce == false then
debounce = true
game.ReplicatedStorage.Shoot:FireServer(game.Players.LocalPlayer:GetMouse().Hit.p, "Gun")
wait(.5)
debounce = false
end
end)
I added a remote event called "Shoot" in replicatedstorage, cuz I want the bullet to be on the server side and not on the client side. Here's the server script in ServerScriptService:
local TweenService = game:GetService("TweenService")
game.ReplicatedStorage.Shoot.OnServerEvent:Connect(function(player, Position, GunName)
local Bullet = game.ReplicatedStorage.Bullet:Clone()
Bullet.Parent = game.Workspace
Bullet.CFrame = CFrame.new(game.Workspace:WaitForChild(player.Name):WaitForChild(GunName).Handle:WaitForChild("Position").WorldPosition, Position)
local goal = {}
goal.Position = Vector3.new(Position)
local tweenInfo = TweenInfo.new(.25)
local tween = TweenService:Create(Bullet, tweenInfo, goal)
tween:Play()
end)
Help will be appreciated!

2 comments
Any errors?
no