Hello. You have to use an in pairs
loop. It loops through a table. Try this:
02 | local ding = game.Workspace.Sounds.Ding |
03 | local parts = { game.Workspace.Configuration.Koala 1 , game.Workspace.Configuration.Koala 2 , game.Workspace.Configuration.Koala 3 } |
04 | local player = game.Players.LocalPlayer |
05 | local mouse = player:GetMouse() |
06 | local UserInputService = game:GetService( "UserInputService" ) |
07 | local gui = player:WaitForChild( "PlayerGui" ) |
08 | local toolup = gui:WaitForChild( "clickE" ) |
10 | local KoalaGUI = player.PlayerGui.KoalaAdd |
13 | local pp = player.leaderstats.Credits |
14 | UserInputService.InputBegan:Connect( function (input,gameProccesedEvent) |
16 | local item = mouse.Target |
17 | local distance = player:DistanceFromCharacter(item.Position) |
18 | for i, part in pairs (parts) do |
19 | if mouse.Target = = part and enabled = = true and distance < = maxpickup and input.KeyCode = = Enum.KeyCode.E or input.KeyCode = = Enum.KeyCode.ButtonB then |
21 | local newkoala = KoalaGUI:Clone() |
22 | newkoala.Parent = game.Players.LocalPlayer.PlayerGui |
23 | newkoala.Enabled = true |
24 | part.Position = Vector 3. new( 100 , 100 , 100 ) |
28 | part.CanCollide = false |
30 | game.ReplicatedStorage.KoalaEvent:FireServer() |
36 | part.CanCollide = true |
Please accept and upvote this answer if it helps.