Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 6 years ago
01part = script.Parent
02 
03part.Touched:Connect(function(hit)
04    if hit.Name == "NodeOrb" and script.Parent.Parent.Parent.Parent.Character.TeamCol.Value == "Tred" then
05        hit.CaptureStatus.Value = hit.CaptureStatus.Value + 1
06    end
07    if hit.Name == "NodeOrb" and script.Parent.Parent.Parent.Parent.Character.TeamCol.Value == "Tblue" then
08        hit.CaptureStatus.Value = hit.CaptureStatus.Value - 1
09    end
10end)

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?

1 answer

Log in to vote
0
Answered by
yHasteeD 1819 Moderation Voter
6 years ago
Edited 6 years ago

For first, on equip the tool. the tool go to Player character. and you dont need to use .Character

Here is a example:

01local tool = script.Parent
02 
03tool.Equiped:Connect(function()
04    print("Player name: " .. script.Parent.Parent.Name)
05    --[[
06     script = Script
07      script.Parent = tool
08       script.Parent.Parent = character.
09    ]]
10end)

Here is fixed script:

01local tool = script.Parent.Parent -- Added variable for tool
02local part = script.Parent -- Use local Variable = ... not Variable = ...
03 
04part.Touched:Connect(function(hit)
05    if tool.Parent:FindFirstChild("Humanoid") then -- Check if is in char.
06        if hit.Name == "NodeOrb" and tool.Parent.TeamCol.Value == "Tred" then
07            hit.CaptureStatus.Value = hit.CaptureStatus.Value + 1
08        end
09        if hit.Name == "NodeOrb" and tool.Parent.TeamCol.Value == "Tblue" then
10            hit.CaptureStatus.Value = hit.CaptureStatus.Value - 1
11        end
12    end
13end)

Hope it helped :D


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 201 — 6y
Ad

Answer this question