Replication Problems

"Hey devforum people, so recently I’ve find my-self into a tricky problem in a game I’m working on, and I would want to ask for some help on it. The problem it-self it’s that, I have a “monster” that basically go and try to catch the players, but my actual problem is that the monster see the players near to it, but for the player it-self, the monster it’s far from it.

Since this is the case, the monster can hit them and deal damage to them when the player it-self, sees the monster far away from it. So this may cause a lot of issues when the player base when the game it’s released, someone know anything that could guide me in the right direction to solve this issue?"

It’s most likely due to desync, how are you positioning it?

Teleporting the users to the map you mean?

How are you moving the monsters position, and how are they receiving and sending their location?

The monster is a client, it’s not a npc.

Oh my bad, so its a Player. That’s really odd then hm.

Yeah I really don’t know the issue could it be the animation I am using for the wildling?

Try with default animations or no animations at all to see if thats the case.

Did you set the NetworkOwnership to the Player? Maybe you should implement sanity checks on the server to detect if the actual monster is close enough to the player, otherwise it’d result as some wonky issues

The monster is a player, I was confused at first too

Should I set the NetworkOwnership to the ‘Monster’ it’s a client tho?

You have to either set it as nil (Server) or the Player (Client)

I think you’d still need to create the NPC on the server side either way though, since the changes aren’t replicating to the other players but the "Monster"s screen is

It’s not a npc it’s a client…

I meant creating the monster on the server side

I don’t know how you’d really manage to implement the monster on the client side though if it’s a player, a reference would be nice to have or some script

--// SERVICES \\--
local ServerStorage = game:GetService("ServerStorage")

local KatanaHandler = {}
KatanaHandler.__index = KatanaHandler

function KatanaHandler.new(owner, model, damage)
	local newKatana = setmetatable({}, KatanaHandler)
	newKatana.Model = model:Clone()
	newKatana.Damage = damage
	newKatana.Owner = owner 
	
	
	newKatana.Model.Parent = owner.Character
	
	local Activated = false
	local HitDeb = false
	
	local Animations = ServerStorage.CloneObjects.Animations
	local Humanoid = owner.Character.Humanoid
	local Animator = Humanoid.Animator
	
	local KatanaAttack1 = Animator:LoadAnimation(Animations.KatanaAttack1)
	local KatanaAttack2 = Animator:LoadAnimation(Animations.KatanaAttack2)
	
	newKatana.Model.Activated:Connect(function()
		if not Activated then
			if math.random(1,2) == 1 then
				KatanaAttack1:Play()
			else
				KatanaAttack2:Play()
			end
			
			Activated = true
			wait(1)
			Activated = false
		end
	end)
	
	newKatana.Model.Handle.Touched:Connect(function(hit)
		local Humanoid = hit.Parent:FindFirstChild("Humanoid")
		local HumanoidRootPart = hit.Parent:FindFirstChild("HumanoidRootPart")
		if Humanoid and Activated and not HitDeb then
			HitDeb = true
			Humanoid:TakeDamage(math.random(10,20))
				
			wait(1)
			HitDeb = false
		end
	end)
end

return KatanaHandler

This is the code for the katana it’s server side there’s no client side :slightly_smiling_face:

Idk how metatables work Maybe you could try checking the Magnitude for the HitPart & the actual Owner that wields the sword? This does seem to be a ModuleScript, which handles both server & client so maybe that could be it as well?

The module itself is on the server side tho

Also I’ve got this gif with the issue https://gyazo.com/f965349696b4c45391cf5c60d3178145

So the other player says that you were right in front of them on their end? If so, it could just be a question of server latency, which not much can be done about it.

One guess I have is setting the monster’s walkspeed on a local script? Does your monster have a sprint key that is updated from a local script?

If you have a sprint mechanism for the monster try and see if it’s possibly the issue by setting it on the server instead of locally?

No, we don’t have a sprint mechanism…