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

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

Asked by 2 years ago
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

Log in to vote
0
Answered by 2 years ago

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)
Ad
Log in to vote
0
Answered by 2 years ago
--[[
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

Answer this question