-
What do you want to achieve? Make my script fully functional without bugs
-
What is the issue? So here
https://gyazo.com/3af0075337923fd1fbc86da20f4dca7d
I bought 2 elements. And when i reach level 10. The Text is supposed to disappear. But it doesnt
in the same time the color changes. Which doesnt make any sense!
but here
https://gyazo.com/6408e8cbb8d921ff207ae5ad1c32faae
when my level is equal to the required level and i didnt buy the item it works!
local function Check(levelrequired,Button)
if level.Value<levelrequired then
TextCloned.Visible=true
TextCloned=Button:WaitForChild("LevelRequired")
TextCloned.Text="Level "..levelrequired
elseif level.Value>=levelrequired then
print(Button)
warn("Dudewth")
TextCloned.Visible=false
Button.ImageColor3=Color3.new(1, 1, 1)
print("color changed")
print("TextRemoved")
end
end
Picture for explorer panel
https://gyazo.com/2a77f55e7b705e4721283e6964770bda
full script:
local player= game.Players.LocalPlayer or game.Players:WaitForChild("LocalPlayer")
local levelfolder=player:WaitForChild("levelfolder")
local level = levelfolder:WaitForChild("Level")
local Mouse=player:GetMouse()
local texttoclone=game.Workspace.Locked
local LevelText=game.Workspace.LevelRequired
KeybindTween=false
local Locked=true
--Variables
local ShopGui=script.Parent
local StoreButton=ShopGui.Shopicon
local ImageAbilities=ShopGui.ImageAbilities
local AbilitiesFrame=ImageAbilities.AbilitiesFrame
local ScrollingFrame=AbilitiesFrame.ScrollingFrame
local Keybind=ShopGui.Keybind
--YesNoFrame
local Elementstochoose=game.Players.LocalPlayer.ElementTochoose
local YesNoFrame=ShopGui.YesNoFrame
local NoButton= YesNoFrame.No
local YesButton= YesNoFrame.Yes
local ImageChange= YesNoFrame.ImageChange
local ElementsRemain= YesNoFrame.ElementsRemaning
Count=player.ElementTochoose.Value
ElementsRemain.Text="Elements Remaning: ".. Count
---Water
local WaterBullet=ScrollingFrame.WaterBullet
local WaterShark=ScrollingFrame.WaterShark
local WaterWave=ScrollingFrame.WaterWave
--Fire
local FireBall=ScrollingFrame.FireBall
local FireBomb=ScrollingFrame.FireBomb
local FireDragon=ScrollingFrame.FireDragon
--Lightning
local LightningBolt=ScrollingFrame.LightningBolt
local LightningWeb=ScrollingFrame.LightningWeb
local ChidoriLightning=ScrollingFrame.ChidoriLightning
--Earth
local EarthDragon=ScrollingFrame.EarthDragon
local EarthSpike=ScrollingFrame.EarthSpike
local EarthWall=ScrollingFrame.EarthWall
--Wind
local WindBlade=ScrollingFrame.WindBlade
local WindBullet=ScrollingFrame.WindBullet
local WindSwirl=ScrollingFrame.WindSwirl
--Lists
local List={
WindSwirl,
WindBullet,
WindBlade,
EarthWall,
EarthSpike,
EarthDragon,
ChidoriLightning,
LightningWeb,
LightningBolt,
FireDragon,
FireBomb,
FireBall,
WaterWave,
WaterShark,
WaterBullet
}
local Elements= {"Water","Fire","Lightning","Earth","Wind"}
for i,v in pairs(List) do
TextCloned=v:WaitForChild("Locked")
end
WindList={
WindBullet,
WindSwirl,
WindBlade,
"Wind",
"6701490292"
}
FireList={
FireBall,
FireBomb,
FireDragon,
"Fire",
"6691763276"
}
WaterList={
WaterBullet,
WaterShark,
WaterWave,
"Water",
"6691759647"
}
LightningList={
LightningBolt,
LightningWeb,
ChidoriLightning,
"Lightning",
"6701475961"
}
EarthList={
EarthWall,
EarthSpike,
EarthDragon,
"Earth",
"6691756490"
}
local folder= game.Players.LocalPlayer:WaitForChild("ElementList")
local Fire= folder.FireList
local Water=folder.WaterList
local Wind=folder.WindList
local Earth=folder.EarthList
local Lightning=folder.LightningList
---assign Buttons
local Z=Keybind.Z
local X=Keybind.X
local C=Keybind.C
local V=Keybind.V
local B=Keybind.B
local N=Keybind.N
local KeybindTween=true
--booleans
local OpenAbillities=true
local OpenKeyBind=true
local Abitlitybind=true
--State
ImageAbilities.Visible=false
Keybind.Visible=false
KeybindsList={
Z,
X,
C,
V,
B,
N,
}
local function Tween()
if KeybindTween then
Keybind.Visible=true
Keybind:TweenPosition(
UDim2.new(0.819, 8,0.37, 0),
Enum.EasingDirection.Out,
Enum.EasingStyle.Sine,
0.2,
false
)
KeybindTween=false
end
end
local function ReverseTween()
if not KeybindTween then
Keybind:TweenPosition(
UDim2.new(1, 8,0.37, 0),
Enum.EasingDirection.Out,
Enum.EasingStyle.Sine,
0.2,
false
)
KeybindTween=true
wait(0.2)
Keybind.Visible=false
end
end
boolean=true
--First
StoreButton.MouseButton1Down:connect(function()
if OpenAbillities then
ImageAbilities.Visible=true
OpenAbillities=false
elseif not OpenAbillities then
ReverseTween()
ImageAbilities.Visible=false
OpenAbillities=true
end
end)
--Stage1
local function ButtonPressed(levelrequired,Button)
local function LevelCheck()
if level.Value>=levelrequired and OpenKeyBind then
Tween()
Keybind.Visible=true
OpenKeyBind=false
Button1=Button
elseif not OpenKeyBind then
ReverseTween()
Keybind.Visible=false
OpenKeyBind=true
end
end
local function Search(List,Identifier,element)
if table.find(List,Identifier) then
game.ReplicatedStorage.CheckiftrueEvent:FireServer(element)
end
end
local function YesNoFramefunc(List2,ButtonValue)
YesNoFrame.Visible=true
ImageChange.Image ="rbxassetid://"..List2[5]
print(List2[5])
YesButton.MouseButton1Down:connect(function()
if boolean then
game.ReplicatedStorage.ElementEvent:FireServer(player,ButtonValue)
print(ButtonValue)
game.ReplicatedStorage.ResultEvent.OnClientEvent:Connect(function(boolean2,Abilityvalue,_)
print(Abilityvalue)
print(boolean)
print(boolean2)
ElementsRemain.Text="Elements Remaning: ".. Abilityvalue
if boolean2 then
Search(FireList,tostring(ButtonValue),Fire)
Search(WaterList,tostring(ButtonValue),Water)
Search(EarthList,tostring(ButtonValue),Earth)
Search(LightningList,tostring(ButtonValue),Lightning)
Search(WindList,tostring(ButtonValue),Wind)
List2[1]:WaitForChild("Locked").Visible=false
List2[2]:WaitForChild("Locked").Visible=false
List2[3]:WaitForChild("Locked").Visible=false
List2[1].ImageColor3=Color3.new(1, 1, 1)
end
ElementsRemain.Text="Elements Remaning: ".. Abilityvalue
end)
YesNoFrame.Visible=false
boolean=false
wait(1)
boolean=true
end
end)
NoButton.MouseButton1Down:connect(function()
YesNoFrame.Visible=false
end)
end
Button.MouseButton1Down:connect(function()
abilitiefolder=game.Players.LocalPlayer.AbilitiesFolder
if Button==WaterList[1] or Button==WaterList[2] or Button==WaterList[3] then
if Water.Value then
LevelCheck()
elseif not Water.Value then
if table.find(WaterList,Button) then
local ButtonValue=abilitiefolder.Water
YesNoFramefunc(WaterList,ButtonValue)
end
end
end
if Button==FireList[1] or Button==FireList[2] or Button==FireList[3] then
if Fire.Value then
LevelCheck()
elseif not Fire.Value then
if table.find(FireList,Button) then
local ButtonValue=abilitiefolder.Fire
YesNoFramefunc(FireList,ButtonValue)
end
end
end
if Button==LightningList[1] or Button==LightningList[2] or Button==LightningList[3] then
if Lightning.Value then
LevelCheck()
elseif not Lightning.Value then
if table.find(LightningList,Button) then
local ButtonValue=abilitiefolder.Lightning
YesNoFramefunc(LightningList,ButtonValue)
end
end
end
if Button==WindList[1] or Button==WindList[2] or Button==WindList[3] then
if Wind.Value then
LevelCheck()
elseif not Wind.Value then
if table.find(WindList,Button) then
local ButtonValue=abilitiefolder.Wind
YesNoFramefunc(WindList,ButtonValue)
end
end
end
if Button==EarthList[1] or Button==EarthList[2] or Button==EarthList[3] then
if Earth.Value then
LevelCheck()
elseif not Earth.Value then
if table.find(EarthList,Button) then
local ButtonValue=abilitiefolder.Earth
YesNoFramefunc(EarthList,ButtonValue)
end
end
end
wait(2)
end)
end
function Assigntokey(button2,keycode)
button2.MouseButton1Down:connect(function()
ReverseTween()
OpenKeyBind=true
keycode1=keycode
game.ReplicatedStorage.AssignEvent:FireServer(n,keycode1,Button1)
end)
end
--Stage2
--FUNCTIONS Running
function remove(List,value)
if value.Value then
print("123")
List[1]:FindFirstChild("Locked").Visible=false
List[2]:FindFirstChild("Locked").Visible=false
List[3]:FindFirstChild("Locked").Visible=false
List[1].ImageColor3=Color3.new(1, 1, 1)
elseif not value.Value then
List[1]:WaitForChild("Locked").Visible=true
List[2]:FindFirstChild("Locked").Visible=true
List[3]:FindFirstChild("Locked").Visible=true
else
end
end
local function Check(levelrequired,Button)
if level.Value<levelrequired then
TextCloned.Visible=true
TextCloned=Button:WaitForChild("LevelRequired")
TextCloned.Text="Level "..levelrequired
elseif level.Value>=levelrequired then
print(Button)
warn("Dudewth")
TextCloned.Visible=false
Button.ImageColor3=Color3.new(1, 1, 1)
print("color changed")
print("TextRemoved")
end
end
ButtonPressed(0,WaterBullet)
ButtonPressed(10,WaterShark)
ButtonPressed(20,WaterWave)
ButtonPressed(0,WindBullet)
ButtonPressed(10,WindSwirl)
ButtonPressed(20,WindBlade)
ButtonPressed(0,FireBall)
ButtonPressed(10,FireBomb)
ButtonPressed(20,FireDragon)
ButtonPressed(0,LightningBolt)
ButtonPressed(10,LightningWeb)
ButtonPressed(20,ChidoriLightning)
ButtonPressed(0,EarthWall)
ButtonPressed(10,EarthDragon)
ButtonPressed(20,EarthSpike)
Assigntokey(Z,"Z")
Assigntokey(X,"X")
Assigntokey(C,"C")
Assigntokey(V,"V")
Assigntokey(B,"B")
Assigntokey(N,"N")
game.ReplicatedStorage.PlayerJoined.OnClientEvent:Connect(function()
remove(LightningList,Lightning)
remove(WaterList,Water)
remove(FireList,Fire)
remove(EarthList,Earth)
remove(WindList,Wind)
if Fire.Value then
Check(0,FireBall)
Check(10,FireBomb)
Check(20,FireDragon)
end
if Earth.Value then
Check(0,EarthWall)
Check(10,EarthSpike)
Check(20,EarthDragon)
end
if Wind.Value then
Check(0,WindBullet)
Check(10,WindSwirl)
Check(20,WindBlade)
end
if Water.Value then
Check(0,WaterBullet)
Check(10,WaterShark)
Check(20,WaterWave)
end
if Lightning.Value then
Check(0,LightningBolt)
Check(10,LightningWeb)
Check(20,ChidoriLightning)
end
end)
player.levelfolder.Level.Changed:connect(function()
for i=3,0,-1 do
wait(0.1)
if Fire.Value then
Check(0,FireBall)
Check(10,FireBomb)
Check(20,FireDragon)
end
if Earth.Value then
Check(0,EarthWall)
Check(10,EarthSpike)
Check(20,EarthDragon)
end
if Wind.Value then
Check(0,WindBullet)
Check(10,WindSwirl)
Check(20,WindBlade)
end
if Water.Value then
Check(0,WaterBullet)
Check(10,WaterShark)
Check(20,WaterWave)
end
if Lightning.Value then
Check(0,LightningBolt)
Check(10,LightningWeb)
Check(20,ChidoriLightning)
end
end
end)
player.ElementTochoose.Changed:connect(function()
for i=3,0,-1 do
wait(0.1)
print('1231231412515')
remove(LightningList,Lightning)
remove(WaterList,Water)
remove(FireList,Fire)
remove(EarthList,Earth)
remove(WindList,Wind)
print("123")
if Fire.Value then
Check(0,FireBall)
Check(10,FireBomb)
Check(20,FireDragon)
end
if Earth.Value then
Check(0,EarthWall)
Check(10,EarthSpike)
Check(20,EarthDragon)
end
if Wind.Value then
Check(0,WindBullet)
Check(10,WindSwirl)
Check(20,WindBlade)
end
if Water.Value then
Check(0,WaterBullet)
Check(10,WaterShark)
Check(20,WaterWave)
end
if Lightning.Value then
Check(0,LightningBolt)
Check(10,LightningWeb)
Check(20,ChidoriLightning)
end
end
end)```
3. **What solutions have you tried so far?** Literally everything i code.a while loop ,for loop
```lua
-- This is an example Lua code block