Hello,
After all of my desperate attempts to make this work, it hasn't been lol. I made a script for a key where if the humanoid touches the key, it is picked up. It will work better for my game if it is picked up if it is clicked. Any help? I will link the script below.
local key = script.Parent:WaitForChild('KeyUnion')
local weld = nil
key.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') then
if game.Players:GetPlayerFromCharacter(hit.Parent) then
if game.Players:GetPlayerFromCharacter(hit.Parent).Team.Name == 'Safe' and key:IsDescendantOf(workspace) and key.Parent.Parent:FindFirstChild('Humanoid') == nil then
key.Parent.Parent = game.Players:GetPlayerFromCharacter(hit.Parent).Backpack
print('hey')
end
end
end
end)
script.Parent.Equipped:Connect(function()
weld = Instance.new('Weld')
weld.Part0 = script.Parent.Parent["Right Arm"]
weld.Part1 = key
weld.C0 = CFrame.new(0, -1, 0) * CFrame.Angles(-0.5 * math.pi, 0, 0)
weld.C1 = script.Parent.Grip
weld.Parent = script.Parent.Parent['Right Arm']
end)
script.Parent.Unequipped:Connect(function()
if weld ~= nil then
weld:Destroy()
weld = nil
end
end)
Thank you in advance.

1 comment
Try using ClickDetectors if you want it to be clicked by something. It could be useful to be able to click and touch the key(because tapping on objects is really difficult on mobile)