script:
function ChangeToolPosition(Tool, Position)
local Tools = {}
for i,v in pairs(Tool.Parent:GetChildren()) do
if v:IsA("Tool") then
table.insert(Tools, v)
end
end
local OldParent = Tool.Parent
local Number = 0
for i,v in pairs(Tools) do
if v:IsA("Tool") then
Number += 1
if Number == 1 then
if Tools[Position + 1] == Tool then
Tool.Parent = script.Tools
elseif v ~= Tool and Number ~= Position - 1 then
v.Parent = script.Tools
end
elseif v ~= Tool and Number ~= Position - 1 then
v.Parent = script.Tools
else
Tools[Position].Parent = script.Tools
end
if Number == Position then
Tool.Parent = script.Tools
elseif Number == Position - 1 then
Tools[Position].Parent = script.Tools
end
end
end
for i,v in pairs(script.Tools:GetChildren()) do
if v:IsA("Tool") then
v.Parent = OldParent
end
end
end
ChangeToolPosition(script.Parent:WaitForChild("Shoot"), script.Parent.Parent:WaitForChild("plrData"):WaitForChild("ToolArrangement"):WaitForChild("Shoot").Value)
ChangeToolPosition(script.Parent:WaitForChild("Pass"), script.Parent.Parent:WaitForChild("plrData"):WaitForChild("ToolArrangement"):WaitForChild("Pass").Value)
ChangeToolPosition(script.Parent:WaitForChild("Long"), script.Parent.Parent:WaitForChild("plrData"):WaitForChild("ToolArrangement"):WaitForChild("Long").Value)
ChangeToolPosition(script.Parent:WaitForChild("Tackle"), script.Parent.Parent:WaitForChild("plrData"):WaitForChild("ToolArrangement"):WaitForChild("Tackle").Value)
ChangeToolPosition(script.Parent:WaitForChild("Dribble"), script.Parent.Parent:WaitForChild("plrData"):WaitForChild("ToolArrangement"):WaitForChild("Dribble").Value)
This is meant for arranging tools according to a datastore value within the player, it does work but in the wrong order.
Shoot = 1
Pass = 2
it would sort it in the wrong order
Pass = 1
Shoot = 2
Doing Wait times wouldn’t work as it would break the tools. what can i do?