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

How can I clone an Item into the Players Inventory?

Asked by 4 years ago
Edited 4 years ago

Hey Guys,

I currently Script on a coustom Dialog Shop System.

and I have a little Question: How can I clone an Item from the ServerStorage into the Players inventory?

Thats my Current Script:

script.Parent.MouseButton1Click:Connect(function()

local Todo = script.Parent.Todo

local plr = game.Players.LocalPlayer

if Todo.Value == "Coke" then

if plr.leaderstats.Cash.Value >= 100 then

plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value - 100

end

Todo.Value = ""

script.Parent.BackgroundTransparency = 1

script.Parent.Text = ""

script.Parent.Parent.Right.BackgroundTransparency = 1

script.Parent.Parent.Right.Text = ""

script.Parent.Parent:TweenPosition(UDim2.new(-2,0,.419,0), "Out", "Quad",1)

script.Parent.Parent.TextLabel.Text = ""

workspace:FindFirstChild(script.Parent.Todo.NPC.Value).BillboardGui.debounce.Value = false

end

end)

Thanks for help :D

1 answer

Log in to vote
0
Answered by
royee354 129
4 years ago

If you want to clone something you use :Clone() also, if you're planning on cloning something from the serverstorage make sure to use a global script because local scripts can't access serverstorage. In your case I'd use a variable that will be the item you want to clone and you'd clone it and then parent it to the backpack of the player. S = game.ServerStorage:WaitForChild("YourItem"):Clone() S.Parent = Player.Backpack

0
And How can I do it in a Local Script? RedstonecraftHD 25 — 4y
0
I would suggest not doing that in a local script because it won't show for other players royee354 129 — 4y
0
wouldnt you use remote events? Bylli_Oruze 38 — 4y
0
he can use remote events, royee354 129 — 4y
Ad

Answer this question