I get 2 errors in output:
attempt to index nil with Parent - Line 6
and
Argument 1 missing or nil - Line 12
I have no idea how to troubleshoot these errors and I need assistance with them if possible.
Code:
local Player = script.Parent.Parent.Parent local Char = Player.Character Char.Hitboxes.Part.Touched:Connect(function(inst) if Char.Hitboxes.Part.Active.Value == true then local player if game:GetService("Players"):GetPlayerFromCharacter(inst.Parent) or inst.Parent:FindFirstChildOfClass("Humanoid").Parent.Name then player = game:GetService("Players"):GetPlayerFromCharacter(inst.Parent) or inst.Parent.Name else print("no") end -------- local Character if player.Character or game.Workspace[player.Name] then Character = player.Character or game.Workspace[player.Name] else print("no") end print(Character) print(Player.Name .. Player.Parent.Name) end end)
don't really understand what you're trying to accomplish with your script, but if theres script.Parent.Parent.Parent then it sets up a new connection every time someone joins.
also, you should pick one and do GetPlayerFromCharacter or Humanoid.Parent.Name.
Detecting the character here is unnecessary. If you get the player with any of the two above, you already know the character will be inst.Parent
part.Touched:Connect(function(object) local character = object.Parent local player = Players:GetPlayerFromCharacter(character) if player and character then print("both player and character detected") end end)
Change
if Char.Hitboxes.Part.Active.Value == true then
to
if Char.Hitboxes.Part.Active.Value == true and inst ~= nil then