Still have questions? Join our Discord server and get real time help.
1

# help with checking the string of a value in the players model?

Asked by 7 months ago
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?

0
yHasteeD 1602
7 months ago
Edited 7 months ago

### For first, on equip the tool. the tool go to Player character. and you dont need to use .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)


## Solved your problems? put in title [SOLVED] or accept a answer.

#### Errors? tell-me on comments.

0
yes! thank you this problem has been annoying to deal with. mantorok4866 50 — 7mo