`local clickDetector =script.parent.ClickDetector local plant = script.Parent.Parent local crop_bool = script.Parent.waitingCrop local base = script.parent.Parent.Parent.Parent local Players = game:GetService("Players") local player_mod local team = base.team.Value
function onMouseClick(player_touch) local player = base.player.Value local player_obj = base.playerObj.Value
if(player_touch.Name == player )then
local screen_gui = player_obj.PlayerGui.ScreenGui
screen_gui.plant1.Visible = true
print(screen_gui.plant1:getFullName())
print(screen_gui.plant1.Visible)
screen_gui.plant1.Selectable = true
screen_gui.plant2.Visible = true
screen_gui.plant2.Selectable = true
crop_bool.Value = true
end
end
clickDetector.MouseClick:connect(onMouseClick)`
This is my script, that set buttons visibility to true, if the player, that touches the part, is the "owner" of the part, otherwise it does nothing. It works, the buttons turn visible.
`local connection local parent = script.Parent local gui = parent.Parent local bases= game.Workspace.Island local base local field function onClick()
if(game.Players.LocalPlayer.Team.Name == gui.team1.Value)then
base = bases.base1
field = base.field1
end
if(game.Players.LocalPlayer.Team.Name == gui.team2.Value)then
base = bases.base2
field = base.field1
end
gui.plant1.Visible = false
gui.plant2.Selectable = false
gui.plant2.Visible = false
gui.plant2.Selectable = false
local children = field:GetChildren()
for i, child in ipairs(children) do if(child.Part.waitingCrop.Value == true)then
child.Part.plantType.plantTypeLabel.Text = parent.Text
end
end end
connection=parent.MouseButton1Click:Connect(onClick)`
That's the script for my buttons, one script per buttons, yet. what it does, is that it compare, two string value, that is respectively, the current user's team, and the possible teams that are in the game, and it also search for a value in the current's user land, if it sees a part, that has a true for his "waitingCrop", it will change the text that is above of it. And it also make buttons invisble.
Now my problem is that, the first script, execute itself correctly for the first time, but when i click again on the part, the buttons doesn't appear visible, when i go searching for the buttons that are affected by the script on the explorer, the properties says that visible is set to false, but when i do a print(screen_gui.plant1.Visible) the console says otherwise, it's true.
i checked it, i always, edit gui on playerGui and not starterGui, since i want to affect only the current's player gui.
i hope someone could help me! thanks
PS: sorry if inline codes aren't showing properly
