part = script.Parent part.Touched:Connect(function(hit) if hit.Name == "NodeOrb" and script.Parent.Parent.Parent.Parent.Character.TeamCol.Value == "Tred" then hit.CaptureStatus.Value = hit.CaptureStatus.Value + 1 end if hit.Name == "NodeOrb" and script.Parent.Parent.Parent.Parent.Character.TeamCol.Value == "Tblue" then hit.CaptureStatus.Value = hit.CaptureStatus.Value - 1 end end)
the script is in a part which is inside a tool, and Im trying to access a stringvalue inside the tool owners character but Im having trouble getting to it, I thought what I had would work but I keep getting an error were the script is trying to get to the stringvalue.
is there something Im doing wrong?
.Character
Here is a example:
local tool = script.Parent tool.Equiped:Connect(function() print("Player name: " .. script.Parent.Parent.Name) --[[ script = Script script.Parent = tool script.Parent.Parent = character. ]] end)
Here is fixed script:
local tool = script.Parent.Parent -- Added variable for tool local part = script.Parent -- Use local Variable = ... not Variable = ... part.Touched:Connect(function(hit) if tool.Parent:FindFirstChild("Humanoid") then -- Check if is in char. if hit.Name == "NodeOrb" and tool.Parent.TeamCol.Value == "Tred" then hit.CaptureStatus.Value = hit.CaptureStatus.Value + 1 end if hit.Name == "NodeOrb" and tool.Parent.TeamCol.Value == "Tblue" then hit.CaptureStatus.Value = hit.CaptureStatus.Value - 1 end end end)