"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?"
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
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
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
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?
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?