So I’m trying to make my script move items from a folder into the players inventory but it isn’t working. I know for sure my script is flawless!
1 | function onClicked(p) |
2 | local ordertools = script.Parent.Parent.Parent.ordertools:GetChildren() |
3 | ordertools.Parent p.Backpack |
4 | end |
5 | script.Parent.ClickDetector.MouseClick:connect(onClicked) |
The Tool just stays in the Folder for some reason!!!
01 | function onClicked(p) |
02 | local ordertools = script.Parent.Parent.Parent.ordertools:GetChildren() |
03 | for _,v in pairs (ordertools) do |
04 | if v:IsA( "Tool" ) then |
05 | v.Parent = p.Backpack |
06 | end |
07 | end |
08 | script.Parent.ClickDetector.MouseClick:connect(onClicked) |
09 |
10 |
11 |
12 |
13 | --credit to theking48989987 |
01 | local AllowedPlayers = { |
02 |
03 | [ "Player1" ] = true , |
04 |
05 | [ "Player2" ] = true , |
06 |
07 | [ "Player3" ] = true , |
08 |
09 | [ "Player4" ] = true , |
10 |
11 | [ "WyattagumsBackUp" ] = true |
12 |
13 | } |
14 |
15 |
16 |
17 | local Tools = game.ServerStorage.ToolsFolder:GetChildren() -- Remember that any :GetChildren() variable will automatically become a table. |
18 |
19 |
20 |
21 | game.Players.PlayerAdded:Connect( function (player) |
22 |
23 | if AllowedPlayers [ player.Name ] then |
24 |
25 | player.CharacterAdded:Connect( function (character) -- CharacterAdded event will give them the tools everytime they respawn. |
26 |
27 | for _, MyTools in pairs (Tools) do |
28 |
29 | if MyTools:IsA( "Tool" ) then |
30 |
31 | MyTools:Clone().Parent = game.Players [ player.Name ] :WaitForChild( "Backpack" ) |
32 |
33 | end |
34 |
35 | end |
36 |
37 | end ) |
38 |
39 | end |
40 |
41 | end ) |
42 |
43 |
44 |
45 | --[[ |
46 |
47 | I suggest you to use UserIDs in AllowedPlayers table just in case they change their name. |
48 |
49 | If you need more help send me a message on Roblox. |
50 |
51 | --]] |
01 | local AllowedPlayers = { |
02 |
03 | [ "Player1" ] = true , |
04 |
05 | [ "Player2" ] = true , |
06 |
07 | [ "Player3" ] = true , |
08 |
09 | [ "Player4" ] = true , |
10 |
11 | [ "WyattagumsBackUp" ] = true |
12 |
13 | } |
14 |
15 |
16 |
17 | local Tools = game.ServerStorage.ToolsFolder:GetChildren() |
18 |
19 |
20 |
21 | -- Here is the Function for the Clicked event. |
22 |
23 |
24 |
25 | game.Players.PlayerAdded:Connect( function (player) |
26 |
27 | game.Workspace.Part.ClickDetector.MouseClick:Connect( function () |
28 |
29 | if AllowedPlayers [ player.Name ] then |
30 |
31 | for _, v in pairs (Tools) do |
32 |
33 | if v:IsA( "Tool" ) then |
34 |
35 | v:Clone().Parent = game.Players [ player.Name ] .Backpack |
36 |
37 | end |
38 |
39 | end |
40 |
41 | end |
42 |
43 | end ) |
44 |
45 | end ) |