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

I can't clone tools by clicking a tool giver?

Asked by 4 years ago

So i made a keycard for my basement which works, but the thing is, i made it so you need to find the card. But the problem is when you click the card AKA tool giver, it only lets 1 person hold it, basically if someone else clicks the tool giver, the keycard from my inventory gets taken away and given to the other player. How do i make it so it just clones the item? This is the script.

local tool = game.ServerStorage.Card
local klone = tool:clone()
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
    if klone.Parent ~= plr.Backpack then
        klone.Parent = plr.Backpack
    end
end)

I got this from this video https://www.youtube.com/watch?v=orJMUz8b5nE

1 answer

Log in to vote
1
Answered by
blockmask 374 Moderation Voter
4 years ago

Well its simple, you made a clone of the tool before the player even clicked the tool giver and every time you say "klone" its referring to the one specific clone. You need to make a clone when the player clicked the tool giver

local tool = game.ServerStorage.Card

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
    local klone = tool:clone()
    if klone.Parent ~= plr.Backpack then
        klone.Parent = plr.Backpack
    end
end)
0
This is correct, accept this answer! NathanTheCraziest 105 — 4y
Ad

Answer this question