My game isn't FE enabled because I still don't know how that's done but my weapon isn't a tool it's in the camera similar to Phantom Forces and no I'm not trying to copy it I just want to make a COD style game but this is the only problem I have.
function createRay() local muzzle = gun[gun.Name].Flash local ray = Ray.new(mouse.Hit.p,(mouse.hit.p-char.Head.Position).unit*s.range) local hit,pos = workspace:FindPartOnRayWithIgnoreList(ray,{char}) if hit then local human = hit.Parent:FindFirstChild("Humanoid") if human then if human.Health >0 then player.PlayerGui.HUD.Crosshair.Hit:Play() player.PlayerGui.HUD.Crosshair.Frame.Hitmarker.Visible = true if hit.Name == "Head" or hit.Parent:IsA("Hat") then human = human.Health - s.dmg * s.multi else human = human.Health - s.dmg end end end end end
The reason I'm not using server scripts is because they can't access the camera so that's why or maybe it can I don't know but it won't work please if someone can explain it to me or tell me what I'm doing wrong that'll be a big help.
I'm not too sure if this works, after rereading it a couple of times it seems to make sense.
If there's any errors please tell me on what line it is on. If you have any questions, i'll do my best to answer them.
Script where the gun is
function createRay() local muzzle = gun[gun.Name].Flash local fire = PathToRemoteFunction:InvokeServer(mouse.Hit.p,(mouse.hit.p-char.Head.Position).unit*s.range, s) if fire == "hit" then player.PlayerGui.HUD.Crosshair.Hit:Play() player.PlayerGui.HUD.Crosshair.Frame.Hitmarker.Visible = true end end
Script that links to the remote
PathToRemoteFunction.OnServerInvoke:Connect(function (player, pos, dir, s) local function FindParts(obj) --used to find the baseparts of an object local list = {} for _,v in ipairs(obj:GetChildren()) do if v:IsA("BasePart") then table.insert(list, v) end end return list end local ray = Ray.new(pos,dir) local hit,pos = workspace:FindPartOnRayWithIgnoreList(ray,FindParts(player.Character)) if hit then local human = hit.Parent:FindFirstChild("Humanoid") if human then if human.Health > 0 then if hit.Name == "Head" or hit.Parent:IsA("Hat") or hit.Parent:IsA("Accessory") then --included accessory since roblox has made them kinda replace hats human = human.Health - s.dmg * s.multi return "hit" else human = human.Health - s.dmg return "hit" end end end end end)
This in theory should replicate the remote onto the server and the damage