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 5 years 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?

1 answer

Log in to vote
0
Answered by
yHasteeD 1819 Moderation Voter
5 years ago
Edited 5 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:

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)

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 — 5y
Ad

Answer this question