So I got a key here that equips whenever you click it on it but as obviously expected, it disappears from its spot afterwards. I want it to function though like how the horror game “The Mimic” has its keys to were they’re like anchored on the floor (I think?) and everyone can pick them up infinite times as long as you don’t already have one on you. This is to prevent players that would’ve found the key first to leave making the key be gone forever or incase you die, it doesn’t permanently disappear from your inventory and you can pick it up again with no problem.
Like this? It clones the key only once and I’m not able to click to pick it up anymore. The only way it lets me is to manually touch it but even then, it equips more than 1 of the same key. Tell me if I’m doing something wrong.
I fixed it a little bit right now. I can pick it up again by clicking on it and it clones properly but this time it’s still letting me collect more than one when already having a previous one equipped and am also able to pick the tool up by stepping on it as a secondary way to equip it which is also what I don’t want.
Would I put the debounce under the “tool.Parent = game.Workspace[player.Name]” line? What would the debounce look like in this situation for the script? Sorry for the inconvenience, I just want it to work properly.
That’s because you didn’t add a script that detect tool inside a player
try this:
local Key = script.Parent.Parent
local function click(player)
local tool = player.Backpack:FindFirstChild(Key) or player.Character:FindFirstChild(Key)
if tool then
local clone = Key :Clone()
clone.Parent = workspace
workspace[player.Name].Humanoid:EquipTool(clone)
end
end
script.Parent.ClickDetector.MouseClick:Connect(click)
Aight, I’m not on studio soo the format is a bit weird.
Yep, should be something like this but there is a small bool error so I have edited it with lots of comments to help explain to @EchoWinds.
BTW @EchoWinds this is the new clone tool script, should only be one script in order to avoid multiple mouse click events.
--gets the key
local Key = script.Parent.Parent
local function click(player)
--Finds the key inside players backpack or players character via the name of the tool
local isKeyAlreadyGiven = player.Backpack:FindFirstChild(Key.Name) or player.Character:FindFirstChild(Key.Name)
--If the tool isn't given
if not isKeyAlreadyGiven then
--then
local clone = Key:Clone()--copies the key
--puts it in the players backpack
clone.Parent = player.Backpack
end
end
script.Parent.ClickDetector.MouseClick:Connect(click)
Thank you so much omg!! Been trying to make this work for the past hour and half or so I got another quick question that’s still regards the key. How can I keep the key in 1 spot without it getting flung whenever you step on it acting as if anchored? Like you know how if you anchor a tool it won’t work? What I’m looking to do is so it acts as if it’s anchored on the floor but in reality isn’t and can still pick it up normally. Once again, The Mimic’s keys would be a great example of what I mean.