Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Tool:Clone().Parent = plr.StarterGear and parent to inventory folder Not Working?

Asked by 4 years ago

so my clone to starter gear is not working and the parent to the inventory folder too any fix??? (Local Script)Code:

01local plr = game.Players.LocalPlayer
02local Players = game:GetService("Players")
03local ReplicatedStorage = game:GetService("ReplicatedStorage")--gets ReplicatedStorage
04local ToolsFolder = ReplicatedStorage:FindFirstChild("Tools")-- gets the tools folder
05local InventoriesFolder = ReplicatedStorage:FindFirstChild("Inventories")-- gets the inventories folder
06local button = script.Parent-- gets the button
07local SpeedCoil = ToolsFolder:FindFirstChild("SpeedCoil")
08print("VariablesDone!")--prints "VariablesDone!"
09--MainScript--
10button.MouseButton1Click:Connect(function()--when a player presses the button in left click
11    print("Pressed")-- when a player presses the button then it will print out "Pressed"
12    local inventory_folder = InventoriesFolder[plr.Name]
13    print("No Errror BRUH")
14    SpeedCoil:Clone().Parent = plr.Backpack
15    SpeedCoil:Clone().Parent = plr.StarterGear
16    SpeedCoil:Clone().Parent = inventory_folder
17    end)

ThankYou!

0
Wait I know how to fix your problem. XLeMysterioX 22 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

So I have a similar game, where I have tool gamepasses.

The problem your making is this:

Compare your code with mine.

01local plr = game.Players.LocalPlayer
0202  local Players = game:GetService("Players")
0303  local ReplicatedStorage = game:GetService("ReplicatedStorage")--gets ReplicatedStorage
0404  local ToolsFolder = ReplicatedStorage:FindFirstChild("Tools")-- gets the tools folder
0505  local InventoriesFolder = ReplicatedStorage:FindFirstChild("Inventories")-- gets the inventories folder
0606  local button = script.Parent-- gets the button
0707  local SpeedCoil = ToolsFolder:FindFirstChild("SpeedCoil")
0808  print("VariablesDone!")--prints "VariablesDone!"
0909  --MainScript--
1010  button.MouseButton1Click:Connect(function()--when a player presses the button in left click
1111      print("Pressed")-- when a player presses the button then it will print out "Pressed"
1212      local inventory_folder = InventoriesFolder[plr.Name]
1313      print("No Errror BRUH")
1414      SpeedCoil:Clone().Parent = plr.Backpack
1515      SpeedCoil:Clone().Parent = plr.StarterGear
1616      SpeedCoil:Clone().Parent = inventory_folder
1717      end)

Now check Mine:

01local id = 10409444
02game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)
03    if purchased and ido == id then
04        game.ServerStorage.Tools.DiamondSword:clone().Parent = plr.Backpack    
05    end
06end)
07game.Players.PlayerAdded:Connect(function(plr)
08    plr.CharacterAdded:connect(function(char)
09        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[char.Name].UserId, id) then
10            game.ServerStorage.Tools.DiamondSword:clone().Parent = plr.Backpack    
11        end
12    end)
13end)

Moderate this in your own way.

Ad
Log in to vote
0
Answered by
Sparks 534 Moderation Voter
4 years ago
Edited 4 years ago

I don't have much experience with the StarterGear folder, but I assume that the server is cloning this folder to your backpack whenever a player spawns. As a result, attempting to put tools in StarterGear from the client may not work. You'd have to use a RemoteEvent.

01local plr = game.Players.LocalPlayer
02local Players = game:GetService("Players")
03local ReplicatedStorage = game:GetService("ReplicatedStorage")--gets ReplicatedStorage
04local ToolsFolder = ReplicatedStorage:FindFirstChild("Tools")-- gets the tools folder
05local InventoriesFolder = ReplicatedStorage:FindFirstChild("Inventories")-- gets the inventories folder
06local button = script.Parent-- gets the button
07local Tool = ToolsFolder:FindFirstChild("SpeedCoil")
08local GiveToolRemote = ReplicatedStorage:WaitForChild("Tools"):WaitForChild("RemoteEvent")
09print("VariablesDone!")--prints "VariablesDone!"
10--MainScript--
11button.MouseButton1Click:Connect(function()--when a player presses the button in left click
12    print("Pressed")-- when a player presses the button then it will print out "Pressed"
13    local inventory_folder = InventoriesFolder[plr.Name]
14    print("No Errror BRUH")
15    GiveToolRemote:FireServer(Tool.Name)
View all 35 lines...
0
I Forgot The Error But It Gives Me A Error Rgboffical_yt 40 — 4y
0
Ok so uhh it gives me an error when i edit the script it red lines in line 21 in the serverscriptservice script Rgboffical_yt 40 — 4y
0
Oh, my bad, I overlooked the variable assignment. I edited the code; try now. Sparks 534 — 4y
0
ok let me try it gtg to bed first Rgboffical_yt 40 — 4y
View all comments (29 more)
0
Sparks I Wanna Ask Something What If i want to buy different items what do i do?? thanks Rgboffical_yt 40 — 4y
0
Oh And Btw FireServer Is Not A Valid memeber Of A Folder Rgboffical_yt 40 — 4y
0
I updated the code snippet. You basically want to add a second parameter to the FireServer() with the tool name, and then look for the tool on the server to make sure it exists. Sparks 534 — 4y
0
Fixed the remote issue as well Sparks 534 — 4y
0
oh o k thanks!! Rgboffical_yt 40 — 4y
0
oof sorry but another one error Expected identifier when parsing expression, got ')' in line 16 Rgboffical_yt 40 — 4y
0
Forgot to add an end to the last if statement lol Sparks 534 — 4y
0
ok i fixed it Rgboffical_yt 40 — 4y
0
FireServer is Not A valid member Of A folder In Local Script Rgboffical_yt 40 — 4y
0
i Mean Infinite yield possible on 'ReplicatedStorage.Tools:WaitForChild("RemoteEvent")' Rgboffical_yt 40 — 4y
0
Updated again... Sparks 534 — 4y
0
im very very sorry Rgboffical_yt 40 — 4y
0
i mean the local script in the button has the infinite yeild Rgboffical_yt 40 — 4y
0
Fixed It But Another problem in the local script in the button Players.Rgboffical_yt.PlayerGui.ScreenGui.Frame.Blue.LocalScript:15: attempt to index nil with 'FireServer' Rgboffical_yt 40 — 4y
0
Sparks Please Help me Rgboffical_yt 40 — 4y
0
Try again Sparks 534 — 4y
0
line 8 in local script Infinite yield possible on 'ReplicatedStorage.Tools:WaitForChild("RemoteEvent")' Rgboffical_yt 40 — 4y
0
Did you use the new code I updated? Sparks 534 — 4y
0
yes Rgboffical_yt 40 — 4y
0
the error is in the local script in the button Please help.Thanks Rgboffical_yt 40 — 4y
0
The code worked for me when I tested it just now. Something else is not functioning properly for you. Sparks 534 — 4y
0
Does "Variables Done" still print? Sparks 534 — 4y
0
Yes Rgboffical_yt 40 — 4y
0
I mean No It Does Not print "Variables Done" Rgboffical_yt 40 — 4y
0
I Checked Again. Should I Try ReCopiying The Code?? Like I Mean All? Rgboffical_yt 40 — 4y
0
Should I? Rgboffical_yt 40 — 4y
0
ok i tiried it AGAIN so it prints variables done BUT Argument 1 missing or nil, Script 'ServerScriptService.ToolGiver', Line 7 Rgboffical_yt 40 — 4y
0
fixed again Sparks 534 — 4y
0
Ok ill try TYSM For Ur Patience Rgboffical_yt 40 — 4y

Answer this question