Hello my names neptune,
One again i need some help with my fighting game strife stadium
Recently i have been getting tired of writing down hundreds of lines of codes to disabled move depending on character
So im trying to disabled all moves in simple line of code
Ive been trying to do it with :GetChildren but i dont really understand how it works
So to put it simple if i put a :GetChildren for every moveset folder and say disable for that variable will it disable all the scripts in that folder?
Heres my script (Local)
local player = game.Players.LocalPlayer
wait(3)
local char = player.Character
local GOT = script.GOT:GetChildren()
local Jackson = script.Jackson:GetChildren()
local Alpha = script.Alpha:GetChildren()
print(char.StrifeChar.Value)
if char.StrifeChar.Value == "GOT" then
GOT.Disabled = false
Jackson.Disabled = true
Alpha.Disabled = true
end
if char.StrifeChar.Value == "Alpha" then
GOT.Disabled = true
Jackson.Disabled = true
Alpha.Disabled = false
end
if char.StrifeChar.Value == "Jackson" then
GOT.Disabled = true
Jackson.Disabled = false
Alpha.Disabled = true
end
Hope you can help
~Neptune
So :GetChildren creates a list of children from the parent, a way to utilize and create an indexing system is as such.
for i,v in pairs(game.Workspace.Folders) do
print(i .. V.Name)
end)
It takes the list, and does it in order, so you can create functions with this to create a shop. Like.
for i,v in pairs(GamepassesList) do
local GamepassID = v.GamepassID.Value --Assume there is a Integer/Number value attached as a child of the gamepass frame.
v.BuyButton.MouseButton1Click:Connect(function()
MarketPlaceService:PromptGamepassPurchase(MyPlr, GamepassID)
end)
So within the frame, there is a gamepass ID, and then there’s a buy button. And we can duplicate these as many times as we want to create a shop/gamepass system.
If you still don’t understand for loops, please go here: Introduction to Scripting | Roblox Creator Documentation
Now what you can do to fix your code is this.
local player = game.Players.LocalPlayer
wait(3)
local char = player.Character
local GOT = script.GOT:GetChildren()
local Jackson = script.Jackson:GetChildren()
local Alpha = script.Alpha:GetChildren()
print(char.StrifeChar.Value)
if char.StrifeChar.Value == "Alpha" then
for i, v in pairs(GOT) do
v.Disabled = false
end)
for i, v in pairs(Alpha) do
v.Disabled = true
end)
for i, v in pairs(Jackson) do
v.Disabled = false
end)
elseif char.StrifeChar.Value == "GOT" then
for i, v in pairs(GOT) do
v.Disabled = true
end)
for i, v in pairs(Alpha) do
v.Disabled = false
end)
for i, v in pairs(Jackson) do
v.Disabled = false
end)
elseif char.StrifeChar.Value == "Jackson" then
for i, v in pairs(GOT) do
v.Disabled = false
end)
for i, v in pairs(Alpha) do
v.Disabled = false
end)
for i, v in pairs(Jackson) do
v.Disabled = true
end)
end
Hope this works.
Btw, this is super inefficient, but it’s just for the example.
1 Like
Yep thats right i learnt for loops before and should of know it would help anyway this is not ineffient since last time liturally all i did was disabled every single script one line at a time
Anyways thanks!
Ok so yea that should work since the variable is the script (aka v) and the index (Aka the number/i) wont be used but is still needed to work anyways thanks again since youve saved hours of time since the amount of line i would have to put in the future would kill me
Now 5 lines have been changed to 2 thanks!
1 Like