Can local scripts use ClickDetector's?

Can local scripts use ClickDetector’s?

So, I’ve been trying to make a tool not clone to a backpack, but to go in the player’s backpack.

Script:

local robot = script.Parent.Robot
	local starterpack = game.StarterPack
	local Players = game:GetService("Players")
 
 	 	script.Parent.ClickDetector.MouseClick:Connect(function(plr)
	        robot.Parent = plr.Backpack 
	 
	end)

But for some reason, nothing say’s on the output, like it just ignored the script.

2 Likes

I tried to make a similar script but it would not work with a local script it would only work with a server script.

1 Like

Yes Clickdetectors can use a script or a local script to receive user input. It works, but it’s a matter of what it’s receiving that doesn’t.

You need to get the local player who clicked it. You’re passing through two different arguments, in this case, “plr” and players", with no correlation.

local player = Players.LocalPlayer

robot.Parent = game.Players.LocalPlayer.Backpack
1 Like