Need Help With script

Hey Everyone! It’s me again…

I have been watching this video by AlvinBlox:

and the problem is whenever I click a key, it is not deleting the item and going into my inventory.

KeyScript:

local module = {}

function module.DropTools(plr,map,position)
	
	
	
	for i, tool in pairs(plr.Backpack:GetChildren()) do
		
		if tool:IsA("Tool") and game.ServerStorage.KeyHandles:FindFirstChild(tool.Name) then
			
			local clone = game.ServerStorage.KeyHandles:FindFirstChild(tool.Name):Clone()
			
			if clone:IsA("Model") then
				clone:SetPrimaryPartCFrame(CFrame.new(position))
			else
				clone.Position = position
			end
			
			clone.Parent = map.Items
			
			tool:Destroy()
			
			end
		
	end
	
	
	
	for i, tool in pairs(plr.Character:GetChildren()) do
		
		if tool:IsA("Tool") and game.ServerStorage.KeyHandles:FindFirstChild(tool.Name) then
			
			local clone = game.ServerStorage.KeyHandles:FindFirstChild(tool.Name):Clone()
			
			if clone:IsA("Model") then
				clone:SetPrimaryPartCFrame(CFrame.new(position))
			else
				clone.Position = position
			end
			
			clone.Parent = map.Items
			
			tool:Destroy()
			
			end
		
	end
	
	
end


function module.Clicked(plr,item)
	if plr then
		if plr.Character and not plr:FindFirstChild("Piggy") then
			
			local position
			
			if item:IsA("Model") then
				position = item.PrimaryPart.Position
			else
				position = item.position
			end
			
			module.DropTools(plr,game.Workspace.Map,position)
			print("Droppped...KeyHandles")
			
			if game.ServerStorage.Tools:FindFirstChild(item.Name) then
				
				local clonedTool = game.ServerStorage.Tools[item.Name]:Clone()
				clonedTool.Parent = plr.BackPack
				
				plr.Character.Humanoid:EquipTool(clonedTool)
				
				item:Destroy()
				
				print("Equipped the new tool!")
				
			end
			
			
		end
	end
end


return module

there are no errors on the output…
Video:


More Screenshots:

Screenshot - KeyModule - Roblox Studio

Screenshot - KeyHandles - Roblox Studio

Screenshot - KeyItems - Roblox Studio

inside

inside2

script Inside of the key models:

local keyModule = require(game.ServerScriptService:WaitForChild("Game Logic").KeyModule)

script.Parent.ClickDetector.MouseClick:Connect(function(plr)

keyModule.Clicked(plr,script.Parent)

end)

Hope you can anwser me soon, if you want more information then just ask.
Thank you!

edit: I would really appreciate an anwser

1 Like

Not sure but perhaps showing the output when you actually clicked the key would be nice. Is anything getting printed? May I ask whats in “KeyHandles” folder.

No, there is no error or anything on the output getting printed. a screenshot of what is in the keyhandles folder:
this
the script in ItemScript:

local keyModule = require(game.ServerScriptService:WaitForChild("Game Logic").KeyModule)

script.Parent.ClickDetector.MouseClick:Connect(function(plr)

keyModule.Clicked(plr,script.Parent)

end)

Idk if this has to do with it, but the error might be because you have the same script 2 times for the Dropitems function

1 Like

I don’t see a reason why he shouldn’t make a piggy/granny game,

He want’s to learn. And I’m supporting him, saying “you shouldn’t make that game” is really discouraging and demotivative. There’s people that love the style of piggy games and he’s just asking a simple question, If you’re gonna be offensive just ignore this topic, Thank you.

1 Like

no its not that…
it might have just been that I have to update my studio…

oop- I found it! I just had to lowercase a p, thank you so much for the help!

1 Like