function OnClicked() game.Lighting["M16A1"]:clone().Parent = player.Backpack end script.Parent.ClickDetector.MouseClick:connect(OnClicked)
Hello I have a problem I try to make a button with dis script that if I push dis button that its copy the item and put it into Player backpack
Can someone make 3 scripts for my - Clone backpack - Clone item and put in backpack if you have Money - a backpack saver script
This is not a request website but
function OnClicked() if game.Players.LocalPlayer.leaderstats.Money.Value >= 100 then --checks if player has 100 or more money game.Lighting.M16A1:Clone().Parent = game.Players.LocalPlayer.Backpack script.Parent.ClickDetector.MouseClick:connect(OnClicked)
@GalaxyFPS_Studios This should work
function OnClicked() if game.Players.LocalPlayer.leaderstats.Money.Value >= 100 then game.ServerStorage.M16A1:Clone().Parent = game.Players.LocalPlayer.Backpack end end script.Parent.ClickDetector.MouseClick:connect(OnClicked)
Also, have the item in ServerStorage, its neater that way
I believe that the abouve script would not work. To detect a clickDetector click, you need a Script, and a Script doesn't have the "LocalPlayer" variable. This Script should work:
local function onMouseClick(player) if player.leaderstats.Money.Value >= 100 then game.ServerStorage.M16A1:Clone().Parent = player.Backpack end end script.Parent.ClickDetector.MouseClick:connect(onMouseClick)
I didn't test it, might not work (I will check ASAP)
Pls accept if this helped
I usually don't call funcitons.. Makes me confused. But the problem is that click detectors are only for bricks and parts in the workspace. Since you're using a GUI or frame in a button do this:
script.Parent.MouseButton1Click:connect(function(player) game.Lighting.M16A1:Clone().Parent = game.Players.LocalPlayer.Backpack end)
To make clear I'm going to show you:
script.Parent.MouseButton1Click:connect(function() --Script here. end) --Use this on text buttons and guis.
On parts use this:
script.Parent.ClickDetector.MouseClick:connect(function() --Script here. end) --Put a ClickDetector in the part and the script in that same part,NOT IN THE CLICKDETECTOR.
If that worked accept the answer :D
Closed as Not Constructive by RubenKan
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?