why are you using remotes? use bindable events?
also you have some many variables but you don’t even use them!
you can do it fully on the server by using bindable events:
local players = game.Players
local parent = script.Parent
local Humanoid = parent:FindFirstChild("Humanoid")
local repli = game.ReplicatedStorage
local chasesNPC = parent.Configs.ChasesNPC
Humanoid.Touched:Connect(function(hit, limb)
if Humanoid.Health <= 0 then return end
local player = players:GetPlayerFromCharacter(hit.Parent)
--if script.Parent.Configs.ChasesNPCs.Value == false and game.Players:FindFirstChild(hit.Parent.Name) or script.Parent.Configs.ChasesNPCs.Value == true then
--wth is this check, it checks if the value is false and hit is a player, or the value is true?
if not chasesNPC.Value and player or chasesNPC.Value then
local human = hit.Parent:FindFirstChild("Humanoid")--why check if plr exists, if you're using it anyway.
if not human then return end
repli.BindableEvent:Fire(player)
end
end)
repli.BindableEvent.Event:Connect(function(player)
player.TeamColor = Color3.new(1, 1, 1)--brickcolor will error.
end)
also even better, just use a function:
local players = game.Players
local parent = script.Parent
local Humanoid = parent:FindFirstChild("Humanoid")
local chasesNPC = parent.Configs.ChasesNPC
local function setTeam(plr)
plr.TeamColor = Color3.new(1, 1, 1)
end
Humanoid.Touched:Connect(function(hit, limb)
if Humanoid.Health <= 0 then return end
local player = players:GetPlayerFromCharacter(hit.Parent)
--if script.Parent.Configs.ChasesNPCs.Value == false and game.Players:FindFirstChild(hit.Parent.Name) or script.Parent.Configs.ChasesNPCs.Value == true then
--wth is this check, it checks if the value is false and hit is a player, or the value is true?
if not chasesNPC.Value and player or chasesNPC.Value then
local human = hit.Parent:FindFirstChild("Humanoid")--why check if plr exists, if you're using it anyway.
if not human then return end
setTeam(player)
end
end)
and even better, just do it directly!
local players = game.Players
local parent = script.Parent
local Humanoid = parent:FindFirstChild("Humanoid")
local chasesNPC = parent.Configs.ChasesNPC
Humanoid.Touched:Connect(function(hit, limb)
if Humanoid.Health <= 0 then return end
local player = players:GetPlayerFromCharacter(hit.Parent)
--if script.Parent.Configs.ChasesNPCs.Value == false and game.Players:FindFirstChild(hit.Parent.Name) or script.Parent.Configs.ChasesNPCs.Value == true then
--wth is this check, it checks if the value is false and hit is a player, or the value is true?
if not chasesNPC.Value and player or chasesNPC.Value then
local human = hit.Parent:FindFirstChild("Humanoid")--why check if plr exists, if you're using it anyway.
if not human then return end
player.TeamColor = Color3.new(1, 1, 1)--directly in if stmt
end
end)
I don’t know why some design choices were made, but hope this helps!
what even is Chasesnpc for btw?