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

How do I get this click giver to dispense only one time?

Asked by
QWJKZXF 88
6 years ago

How do I get the clicker giver to dispense a tool only one time. I tried this code but doesn't work.

playerNameList = {}
    function onClicked(player)
    local playerName = player.Name
    local executeFunction = true;
    --Check to see if the player has clicked before
    --This will not execute if the value is false or nil. 
    if(playerNameList[playerName]) then
        executeFunction = false;
    end
    if(executeFunction) then
        function onClicked(part)

local player = game.Players.LocalPlayer
local giver = game.Players:FindFirstChild(""..player.Name.."")
print("Clicked")
if player ~= nil then
local wep = game.Lighting.SCAR:clone() -- Change NAME to your model name and put it in the Lighting.
wep.Parent = giver.Backpack
end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
    end 
    playerNameList[playerName] = true
  end
  script.Parent.ClickDetector.MouseClick:connect(onClicked)

0
line 10: if executeFunction == true then greatneil80 2647 — 6y

Answer this question