Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Script which Clones the SMG in ReplicatedStorage and put it in Inv doesn't work ideas why?

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function() --don't mind this
	script.Parent.Parent.Visible = false
end) --dont mind this

function parentPressed()
	game.ReplicatedStorage.SMG:Clone(function(). --this function aint working
		game.ReplicatedStorage.SMG.Parent = player.backpack
	end)
end
script.Parent.MouseButton1Down:connect(parentPressed)

This aint working please help

2 answers

--[[
Cloning something with a local script wont work very well.

I have never made clone into a function so idk how that works but you could use the part that I made below (only errors that I saw were the . after the function() and player.backpack the backpack needs to be capicalized)
]]

game.ReplicatedStorage.SMG:Clone().Parent = player.Backpack

use remote events

-- local script

script.Parent.MouseButton1Click:Connect(function()
       RemoteEvent:FireServer()
end)

-- ServerScript

RemoteEvent.OnServerEvent:Connect(function(plr)
       local SMG = game.ReplicatedStorage.SMG:Clone()
       SMG.Parent = plr.Backpack
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.