Basically I want the bullet that gets created to shoot in the direction of where the Crosshair (ImageLabel) is, Unfortunately I can’t get the script to work for some reason…
My local script for gun:
local RemoteEvent2 = replicatedStorage:WaitForChild("ShotEvent2")
local MobileCrosshair = player.PlayerGui.Mobile.Crosshair
ShootMobile.TouchTap:Connect(function()
if gun.Ammo.Value > 0 then
RemoteEvent2:FireServer(BulletAimer.Position, gun.Handle.Orientation, MobileCrosshair.Position)
gun_Shot:Play()
gun.Ammo.Value += -1
else
empty_Clip:Play()
end
end)
Maybe instead of using the crosshair as the direction you could use the cameras direction? It would make it so the bullet will fly towards whatever direction the camera is facing
I think your problem is the fact that you try to use a GUI 2d position as the destination. Instead of using MobileCrosshair.Position, try using Vector3.new(MobileCrosshair.Position.X, MobileCrosshair.Position.Y, maxDist)(maxDist is where the bullet should stop moving and despawn)
local RemoteEvent2 = replicatedStorage:WaitForChild("ShotEvent2")
local MobileCrosshair = player.PlayerGui.Mobile.Crosshair
ShootMobile.MouseButton1Click:Connect(function()
if gun.Ammo.Value > 0 then
RemoteEvent2:FireServer(BulletAimer.Position, gun.Handle.Orientation, MobileCrosshair.Position)
gun_Shot:Play()
gun.Ammo.Value += -1
else
empty_Clip:Play()
end
end)