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

I Cant Move a tool To starter pack when you click a button?

Asked by 4 years ago
Edited 4 years ago

hello I cant move A tool into starterpack when you click it. I am going in pretty Blinefolded On this one. The only idea that i have is this.

01<pre class="brush: lua">local model = game.workspace.Joe2
02local plr = game.Players.LocalPlayer
03local E = game.Workspace.THing
04 
05game.Workspace.Radio.ClickDetector.MouseClick:Connect(function()
06    E.Parent = StarterPack  <------------------------ This is The Code
07    game.Workspace.Radio:Destroy()
08    for _,part in pairs(model:GetChildren()) do
09        if part : IsA("BasePart") then
10            part.Anchored = false
11            wait(10)
12            part.Anchored = true
13 
14        end
15        game.StarterGui.QuestGui.Reward.Visible = true
16    end
17 
18end)
19</pre>

Anybody have any idea on how i can fix this?

2 answers

Log in to vote
0
Answered by 4 years ago

First of all: Use a server script to replicate tools to the player. Assuming you’re using a local script it won’t work. You can’t use local player in a server script btw

Secondly: You can put your tool into the replicated storage, and use the Clone() function to clone it to the players backpack.

Example code:

1game.Players.PlayerAdded:Connect(function(player)
2script.Parent.ClickDetector:MouseClick:Connect(function()
3local Clone = game.ReplicatedStorage.YourToolName:Clone()
4Clone.Parent = player.Backpack
5end)
6end)
7end

Did not test, let me know if the example code works if you do try it yourself

0
It didint work i think i placed it wrong, You can take a look at my own answer Iownrobloxp 44 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

It Didint work I think I placed it wrong

game.Workspace.Radio.ClickDetector.MouseClick:Connect(function() game.Players.PlayerAdded:Connect(function(player) script.Parent.ClickDetector:MouseClick:Connect(function() local Clone = game.ReplicatedStorage.THing:Clone() Clone.Parent = player.Backpack

01game.Workspace.Radio:Destroy()
02for _,part in pairs(model:GetChildren()) do
03    if part : IsA("BasePart") then
04        part.Anchored = false
05        wait(10)
06        part.Anchored = true
07 
08    end
09    game.StarterGui.QuestGui.Reward.Visible = true
10end

end) end) end)

Answer this question