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

How to fix LocalScript still disabled even when conditions are successfully met?

Asked by
R0jym 47
2 years ago

Hello, I'm new to scripting as I just started out a week ago, I'm trying to make a script where the LocalScript inside the TextButton will be enabled when the part (Which is named pad) gets a new BrickColor

The BrickColor of the part is changed with a script that detects the player's TeamColor (In this instance, the TeamColor is maroon) I just took this script out from a model and placed in the part, this is the script that I took out:

local pad = script.Parent


function onTouch(hit) 
local user = game.Players:GetPlayerFromCharacter(hit.Parent) 
if user ~= nil then 
pad.BrickColor = user.TeamColor 

end 
end 

script.Parent.Touched:connect(onTouch)

This is the second "Separated" script I made inside the part:

local button = game.StarterGui.ScreenGui.TextButton.LocalScript
local pad = script.Parent

if pad.BrickColor == BrickColor.new("Maroon") then
    button.Disabled = false
end

In conclusion, the script that I took out from a model works except for the script that I made, the TextButton's LocalScript still remains disabled even when the part's BrickColor changed to what the second script is looking for

Sorry if it's somehow confusing, like I just said I just started out scripting a week ago, thanks for any feedbacks

Answer this question