I sadly am completely new to scripting, but I’m trying to learn. I made a small simple quest where, if a player finds the ‘hidden camera’, they get to keep it in their backpack as a present.
So far, I’ve managed to make it able for players to click the camera and equip it in their backpack. The only problems I’ve been having that I can’t seem to figure out (or find a post about it on the forum),
is that when another player clicks the camera, it disappears from the backpack from the first player. It seems like only one player is able to equip the camera in the whole sever I was thinking about duplicating the camera tool in ServerStorage to the same amount of the max server player size, but I believe that wouldn’t really resolve the problem.
This is the script I’m using for equipping the camera tool:
local tool = game.ServerStorage["Matt's Camera"] local klone = tool:clone() script.Parent.ClickDetector.MouseClick:connect (function(plr) if klone.Parent ~= plr.Backpack then klone.Parent = plr.Backpack else end end)
local tool = game.ServerStorage["Matt's Camera"]
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
if not plr.Backpack:FindFirstChild("Matt's Camera") and not plr.Character:FindFirstChild("Matt's Camera") then
local clonedTool = tool:Clone()
clonedTool.Parent = plr.Backpack
end
end)
This will check if the player has the tool in either his backpack or character. Tools that are unequipped are stored in the backpack while tools that are equipped are stored in the the character. Then we clone the tool and parent it to the player’s backpack.
Make sure your camera in workspace is a model rather than a tool.
Now type this script
script.Parent.ClickDetector.MouseClick:Connect(function(player)
local Tool = game.ServerStorage.Camera:Clone() -- change this to your item's name
Tool.Parent = player.Backpack or player.Character -- making the Camera's parent to the player's character or Backpack.
script.Parent:Destroy()
end)
Yeah, but when you destroy the part, it will destroy for everyone, making it impossible for anyone else to get the camera. A better way of doing this is checking if the tool exists in either the backpack or the character, then if it doesn’t, clone it and parent it to the player’s backpack. (see my post above)
local tool = game.ServerStorage["Matt's Camera"]
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
local klone = tool:Clone()
if plr.Backpack:FindFirstChild("Matt's Camera") == nil then
klone.Parent = plr.Backpack
end
end)
Simply move the klone local inside of the function
and change if klone.Parent ~= plr.Backpack then to if plr.Backpack:FindFirstChild("Matt's Camera") == nil then