You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to make my Team button work and make it show the gui -
What is the issue? Include screenshots / videos if possible!
When I click on the Teams button, it doesn’t showup the teams gui. - What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried rewriting it and all that, but nothing works.
Script:
local Player = game:GetService('Players').LocalPlayer
local Shared = game:GetService('ReplicatedStorage'):WaitForChild('Shared')
do -- Animations
local Frame = script.Parent:WaitForChild('Animations')
local AnimationsPlaying = {}
local HoldingALoop = {}
local function HandleAnimationsClick(table, name)
local start = table.start
local loop = table.loop
local finish = table.finish
local humanoid = Player.Character:FindFirstChild('Humanoid')
if not humanoid then return end
if not AnimationsPlaying[name] then
AnimationsPlaying[name] = 1
end
if AnimationsPlaying[name] == 1 then
-- Play animation then play the loop
if start then
-- play
local instance = Instance.new('Animation', humanoid) instance.AnimationId = start
local anim = humanoid:LoadAnimation(instance)
anim:Play()
wait(anim.Length)
end
if loop then
-- play
if name =='Pushups' then
Player.Character.Humanoid.WalkSpeed = 0
end
local instance = Instance.new('Animation') instance.AnimationId = loop
local anim = humanoid:LoadAnimation(instance)
anim:Play()
HoldingALoop[name] = anim
end
print('Play animation then play the loop')
AnimationsPlaying[name] = 2
elseif AnimationsPlaying[name] == 2 then
-- End the animation
if HoldingALoop[name] then
HoldingALoop[name]:Stop()
HoldingALoop[name] = nil
end
if finish then
-- play
local instance = Instance.new('Animation') instance.AnimationId = finish
local anim = humanoid:LoadAnimation(instance)
anim:Play()
wait(anim.Length)
anim:Stop()
end
if name =='Pushups' then
Player.Character.Humanoid.WalkSpeed = 16
end
print('End the animation')
AnimationsPlaying[name] = 1
end
end
local Animations = {
['Salute'] = {
start = 'rbxassetid://3534418531',
loop = 'rbxassetid://3534420241',
finish = 'rbxassetid://3534416462',
},
['AtEase'] = {
start = 'rbxassetid://3534409407',
loop = 'rbxassetid://3534412059',
finish = 'rbxassetid:///3534414271',
},
['Pushups'] = {
loop = 'rbxassetid://3534406554',
},
}
spawn(function()
for _, v in next, Frame:WaitForChild('Main'):WaitForChild('Animations'):GetChildren() do
if v:IsA('TextButton') then
v.MouseButton1Click:Connect(function()
HandleAnimationsClick(Animations[v.Name], v.Name)
end)
end
end
end)
script.Parent:WaitForChild('AnimationsButton').MouseButton1Click:Connect(function()
Frame.Main.Visible = not Frame.Main.Visible
end)
end
do -- Gamepasses
local Gamepasses = require(Shared:WaitForChild('Modules').Gamepasses)
local Frame = script.Parent:WaitForChild('Gamepasses')
local MarketplaceService = game:GetService('MarketplaceService')
local List
local List1 = Frame:WaitForChild('Main'):WaitForChild('Gamepasses1')
local List2 = Frame:WaitForChild('Main'):WaitForChild('Gamepasses2')
local Blur = Instance.new('BlurEffect', game:GetService('Lighting'))
Blur.Size = 3
Blur.Enabled = false
local ListMax = 9 -- +1 for the UIGridLayout
local Size = 0
local Template = Frame:WaitForChild('Template')
local function new_pass(name, id, type)
id = id[1]
if #List1:GetChildren() >= ListMax then
List = List2
else
List = List1
end
local info = MarketplaceService:GetProductInfo(id, type)
if info.IsForSale then
local new = Template:Clone()
if type == Enum.InfoType.GamePass then
name = info.Name
else
name = name
end
new.ItemName.Text = name
new.Price.Text = "R$"..info.PriceInRobux
new.ImageLabel.Image = 'rbxassetid://'..info.AssetId
new.Parent = List
new.Visible = true
return new, id
else
print('not on sale')
end
end
spawn(function()
for name, id in next, Gamepasses do
local new = new_pass(name, id, Enum.InfoType.GamePass)
if new then
new.Buy.MouseButton1Click:Connect(function()
MarketplaceService:PromptGamePassPurchase(Player, id[1])
end)
end
end
end)
local function product(new, id)
new.Buy.MouseButton1Click:Connect(function()
MarketplaceService:PromptProductPurchase(Player, id)
end)
end
product(new_pass('$500', {637123760}, Enum.InfoType.Product))
product(new_pass('$2,000', {637124024}, Enum.InfoType.Product))
product(new_pass('$5,000', {637125167}, Enum.InfoType.Product))
script.Parent:WaitForChild('GamepassButton').MouseButton1Click:Connect(function()
Frame.Main.Visible = not Frame.Main.Visible
Blur.Enabled = not Blur.Enabled
end)
end
do -- Teams
local TeamsFrame = script.Parent:WaitForChild('Teams')
local Remote = Shared:WaitForChild('Remotes'):WaitForChild('Team')
local TeamModule = require(Shared:WaitForChild('Modules'):WaitForChild('Teams'))
local Template = TeamsFrame:WaitForChild('Template')
local List = TeamsFrame:WaitForChild('Main'):WaitForChild('Teams')
local Size = 0
local Blur = Instance.new('BlurEffect', game:GetService('Lighting'))
Blur.Size = 3
Blur.Enabled = false
local function new_team(name, color)
Size = Size + 0.082
TeamsFrame:WaitForChild('Main').Size = UDim2.new(0.15, 0, Size, 0)
local newcolor = color.Color
local new = Template:Clone()
new.BackgroundColor3 = newcolor
new.Text = name
new.Parent = List
new.Visible = true
return new
end
local new = new_team('Visitors', BrickColor.new('Mid gray')) -- ??
new.MouseButton1Click:Connect(function()
Remote:FireServer({'SwitchTeam', 'Visitors'})
end)
for name, table in next, TeamModule do
local new = new_team(name, table.color)
new.MouseButton1Click:Connect(function()
Remote:FireServer({'SwitchTeam', name})
end)
end
script.Parent:WaitForChild('TeamButton').MouseButton1Click:Connect(function()
TeamsFrame.Main.Visible = TeamsFrame.Main.Visible
Blur.Enabled = Blur.Enabled
end)
end