First it should be said that you have no reason to continuously use script.Parent when you already have a variable for it.
Anyways, your problem is line 09.
On line 8, you use a rather clever way to make the frame visible or invisible based on the TeamColor, but then you just go ahead and make it visible on line 09, making line 8 useless!
You could simply take out line 9;
local function Check()
Frame.Visible = Player.TeamColor == TeamColor
Frame:TweenPosition(UDim2.new(0.15, 0, 0.15, 0), "Out", "Bounce", 1)
wait(4)
Frame:TweenPosition(UDim2.new(0.15, 0, -0.7, 0), "Out", "Bounce", 1)
wait(2)
Frame.Visible = false
end
But then you're tweening the GUI no matter what -- Not exactly super efficient. You could do this;
local function Check()
if Player.TeamColor == TeamColor then
Frame.Visible = true
Frame:TweenPosition(UDim2.new(0.15, 0, 0.15, 0), "Out", "Bounce", 1)
wait(4)
Frame:TweenPosition(UDim2.new(0.15, 0, -0.7, 0), "Out", "Bounce", 1)
wait(2)
Frame.Visible = false
end
end
Or if you only want the GUI to show when they FIRST join the team, and not when they respawn or anything, you can use the built in parameter of Changed events (it's equal to the property that fired the event);
local function Check(property)
if property == "TeamColor" and Player.TeamColor == TeamColor then
Frame.Visible = true
Frame:TweenPosition(UDim2.new(0.15, 0, 0.15, 0), "Out", "Bounce", 1)
wait(4)
Frame:TweenPosition(UDim2.new(0.15, 0, -0.7, 0), "Out", "Bounce", 1)
wait(2)
Frame.Visible = false
end
end
3 comments
thank you very much for helping, but this doesn't work :( local function Check(property) if property == "TeamColor" and Player.TeamColor == TeamColor then Frame.Visible = true Frame:TweenPosition(UDim2.new(0.15, 0, 0.15, 0), "Out", "Bounce", 1) wait(4) Frame:TweenPosition(UDim2.new(0.15, 0, -0.7, 0), "Out", "Bounce", 1) wait(2) Frame.Visible = fa
Oh, dont worry - got it working ;) thanks for your help!
What exactly wasn't working?