Hi, this is my first post on Devforum so sorry for any mistakes in the text!
Ok, now to my issue. I’m working on a simple fightning game where all the players fight with swords. I’m pretty new to scripting so I’m making the game simple. The game works so that when you load or spawn into the game there is a table infront of you with a sword so when you click the sword it gets placed in your inventory. That the sword goes into your backpack works well, but my issue is that I want it to clone when it’s picked up by a player so that others can pick it up. I have tried a few ways that I found on the internet but it still doesn’t work. If anyone here has a solution, please reply to me. Thank you!
Here is my script:
-- The script is in the handle of the sword
--To make the Sword clickable so you can pick it up
local tool = script.Parent.Parent
local clickdetector = script.Parent.ClickDetector
local function pickup(player)
tool.Parent = game.Workspace[player.Name]
while true do --To make it so that the sword clones on the table so that other players can pick it up
wait(.5)
if tool.Parent == not game.Workspace then
tool:Clone().Parent = workspace
end
end
end
clickdetector.MouseClick:Connect(pickup)
local touchinterest = script.Parent:FindFirstChild("TouchInterest")
touchinterest:Destroy()
-- This is to make sure that you can only collect the Sword by clicking it, not touching it
This is my first post on DevForum so sorry for any mistakes in the text🙃