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

Touched script won't work properly, does not change values its supposed to?

Asked by 6 years ago
Edited 6 years ago
while true do
    wait(.000001)
script.Parent.Touched:connect(function(a)
    if a.Name == "Left Leg" or a.Name == "Right Leg" then
        player = game.Players:GetPlayerFromCharacter(a.Parent)
        if player.TeamColor == BrickColor.new("Brigh red") then
            script.Parent.Parent.RedCapturing.Value = true
        elseif player.TeamColor == BrickColor.new("Bright blue") then
            script.Parent.Parent.BlueCapturing.Value = true
        end
    end
end)


script.Parent.TouchEnded:connect(function(a)
    if a.Name == "Left Leg" or a.Name == "Right Leg" then
        player = game.Players:GetPlayerFromCharacter(a.Parent)
        if player.TeamColor == BrickColor.new("Bright red") then
            script.Parent.Parent.RedCapturing.Value = false
        elseif player.TeamColor == BrickColor.new("Bright blue") then
            script.Parent.Parent.BlueCapturing.Value = false
        end
    end
end)
end

I made this script here inside a part that basically detects whether or not it was touched, what the players team is, and if its a certain team, then a certain value changes. Now, the player is on a team, it is either red or blue, and the script.Parents all correctly align to where they're supposed to go, but the values do not change, and there isn't any problem report in the output, and I have no idea why, can anyone explain? :/

Answer this question