-
What do you want to achieve?
I need it so when the gun is fired the replicated it fires in the players mouse direction instead of someone elses mouse position. -
What is the issue?
At the moment everything works fine but when you fire a bullet to the players mouse position it works fine but to other players it shows the bullet going to there mouse position instead of the person that shot it so the bullet is wacky. -
What solutions have you tried so far?
I have tried to have the bullet follow a cloned bullet which then works but then i have to get really close to a player to do damage as shown here: https://i.gyazo.com/7a896dbf8e7387eee5603f0b92e8b892.mp4
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
This is the code from the replication side when using Mouse Hit Position which gives me what im looking for apart from the fact you need to go close to the player to damage them as it seems the tween stops before it hits the player (And I don;t get the result im looking for when using Velocity as there is bullet drop I want to remove bullet drop)
local tweenService = game:GetService("TweenService")
local plr = game.Players.LocalPlayer
local cooldown = false
local MOUSE = plr:GetMouse()
game.ReplicatedStorage.Ray.OnClientEvent:Connect(function(plr,ray,position,mouse,player,distance,origin,chamber,MouseHit,Damage)
local Bullet = Instance.new("Part")
Bullet.Parent = workspace
Bullet.Anchored = false
Bullet.CanCollide = false
Bullet.Material = Enum.Material.Neon
Bullet.BrickColor = BrickColor.Yellow()
local LasterDist = (origin - position).magnitude
Bullet.Size = Vector3.new(0.168, 0.166, 3.406)
Bullet.Position = origin
Bullet.CFrame = CFrame.new(Bullet.Position, MOUSE.Hit.p)
Bullet.Touched:Connect(function(hit)
if cooldown == true then return end
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent == plr.Character then return end
cooldown = true
script.RemoteEvent:FireServer(hit.Parent.Humanoid, Damage)
script.RemoteEvent.HitSound:Play()
Bullet:Destroy()
wait(0.1)
cooldown = false
end
end)
local FakeBullet = game.Lighting.FakeBullet:Clone()
FakeBullet.Parent = workspace
FakeBullet.Position = chamber
Bullet.Touched:Connect(function(hit)
if hit:IsA("Terrain") then
wait(0.04)
Bullet:Destroy()
end
end)
local tweenInfo = TweenInfo.new(0.3, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
tweenService:Create(Bullet, tweenInfo, {Position = MouseHit}):Play()
Bullet.Velocity = Bullet.CFrame.LookVector * 500
end)
As you can see in this video the bullet goes towards the mouse of the other person instead of the person who shot it.
https://i.gyazo.com/abda33d035dae0cc0d3920e3634669eb.mp4
(Sorry if I didn’t explain it the best but the videos will help you understand.