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 3 years ago
Edited 3 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.




local model = game.workspace.Joe2
local plr = game.Players.LocalPlayer
local E = game.Workspace.THing

game.Workspace.Radio.ClickDetector.MouseClick:Connect(function()
    E.Parent = StarterPack  <------------------------ This is The Code
    game.Workspace.Radio:Destroy()
    for _,part in pairs(model:GetChildren()) do
        if part : IsA("BasePart") then
            part.Anchored = false
            wait(10)
            part.Anchored = true

        end
        game.StarterGui.QuestGui.Reward.Visible = true
    end

end)

Anybody have any idea on how i can fix this?

2 answers

Log in to vote
0
Answered by 3 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:

game.Players.PlayerAdded:Connect(function(player)
script.Parent.ClickDetector:MouseClick:Connect(function()
local Clone = game.ReplicatedStorage.YourToolName:Clone()
Clone.Parent = player.Backpack
end)
end)
end

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 — 3y
Ad
Log in to vote
0
Answered by 3 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

game.Workspace.Radio:Destroy()
for _,part in pairs(model:GetChildren()) do
    if part : IsA("BasePart") then
        part.Anchored = false
        wait(10)
        part.Anchored = true

    end
    game.StarterGui.QuestGui.Reward.Visible = true
end

end) end) end)


Answer this question