I am scripting a gun using fastcast, but i have a problem. I cant compare the character i found in client side with the character i found in the server side.
I don’t really know how to explain it so i will show some samples of the code.
Local script:
local function OnRayHit(cast, result, segmentvelocity, bullet)
bullet:Destroy()
if result.Instance then
local hit = result.Instance
local char = hit:FindFirstAncestorWhichIsA("Model")
if char then
local humanoid = char:FindFirstChild("Humanoid")
if humanoid then
script.Parent.RegisterHitEvent:FireServer(char,hit)
end
end
end
end)
Server Script:
script.Parent.RegisterHitEvent.OnServerEvent:Connect(function(player,character,hit)
for i,v in pairs(game.Workspace:GetChildren()) do --Look for everything inside game.Workspace
if v:FindFirstChildWhichIsA("Humanoid") then --Filter the models with humanoids
if (character.PrimaryPart.Position - v.PrimaryPart.Position).Magnitude > 5 then
if v == character then --CANT COMPARE CHARACTER WITH CHARACTER
print(character) --DOSENT PRINT
print(hit) --DOSENT PRINT
end
end
end
end
end)