Trying to make a gear giving script but failed

Hello! so I’ve been trying to make it so *** only I*** can give people a flamethrower gear I made, it wont work. Here’s how it supposed to work, I type `/e " Player or Random " " Tool " that’s in replicated storage is supposed to go to their inventory when I do enter. It didn’t work though and this is what cam in the output,

  10:47:32.100  ServerScriptService.ToolPasserScript:3: attempt to call a RBXScriptSignal value  -  Server - ToolPasserScript:3
  10:47:32.100  Stack Begin  -  Studio
  10:47:32.100  Script 'ServerScriptService.ToolPasserScript', Line 3  -  Studio - ToolPasserScript:3
  10:47:32.100  Stack End  -  Studio

Here’s the script

local ReplicatedStorage = game:GetService("ReplicatedStorage")

game.Players.PlayerAdded(function(player)
	player.Chatted:Connect(function(text)
		if userId = 1900786800
		local text = string.lower(text)
		
		local Tool
		for i,v in pairs(ReplicatedStorage.Tools:GetChildren()) do
			local ToolName = string.lower(v.Name)
			
			if string.find(text, ToolName) then
				Tool = v.Name
				
			end
		end
		
		local Receiver
		for i,player in pairs(game.Players:GetPlayers()) do
			local playerName = string.lower(player.Name)
			
			if string.find(text, playerName) then
				Receiver = player
			end
		end
		
		if Tool and Receiver then
			local Backpack = Receiver.Backpack
			local newTool = ReplicatedStorage.Tools:FindFirstChild(Tool) :Clone()
		end
	end)
end)

This came inside the output when I changed it so someone with a userId " my user Id " can only do it

  10:54:21.747  ServerScriptService.ToolPasserScript:5: Expected 'then' when parsing if statement, got '='  -  Studio - ToolPasserScript:5
2 Likes

On line 3, you put

game.Players.PlayerAdded(function(player)

you need to put

game.Players.PlayerAdded:Connect(function(player)
3 Likes

Also, on the line where you put if UserId = 1900786800, it’s supposed to be if Player.UserId == 1900786800 then

1 Like

@maturegotit @ShesSoCuteeee

Where’s line 33 exactly? Can you show us?

1 Like

theirs no line 33 on my end so I might have missed something

1 Like

Remove the if UserId = 1900786800. I’m pretty sure that’s causing the error

2 Likes

Its still not working after I removed it, nothings coming into the Output eatheir exept for Unable to load pluging.

1 Like

Try this.
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)

game.Players.PlayerAdded(function(player)
player.Chatted:Connect(function(text)
	local text = string.lower(text)

	local Tool
	for i,v in pairs(ReplicatedStorage.Tools:GetChildren()) do
		local ToolName = string.lower(v.Name)

		if string.find(text, ToolName) then
			Tool = v.Name

		end
	end

	local Receiver
	for i,player in pairs(game.Players:GetPlayers()) do
		local playerName = string.lower(player.Name)

		if string.find(text, playerName) then
			Receiver = player
		end
	end

	if Tool and Receiver then
		local Backpack = Receiver.Backpack
		local newTool = ReplicatedStorage.Tools:FindFirstChild(Tool):Clone()
		newTool.Parent = Backpack
	end
   end)
end)
1 Like
  11:53:01.694  ServerScriptService.ToolPasserScript:30: Expected 'end' (to close 'function' at line 2), got <eof>; did you forget to close 'then' at line 25?  -  Studio - ToolPasserScript:30
  11:53:06.677   ▶ Unable to load plugin icon. (x2)  -  Studio

didn’t work

Perhaps it’s

local ReplicatedStorage = game:GetService("ReplicatedStorage")

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(text)
		if player.UserId == 1900786800 then
			local lowertext = string.lower(text)
			
			local Tool,Receiver
			
			for i,v in pairs(ReplicatedStorage.Tools:GetChildren()) do
				local ToolName = string.lower(v.Name)
				
				if string.find(lowertext, ToolName) then
					Tool = v.Name
					
				end
			end
			
			for i,player in pairs(game.Players:GetPlayers()) do
				local playerName = string.lower(player.Name)
				
				if string.find(lowertext, playerName) then
					Receiver = player
				end
			end
			
			if Tool and Receiver then
				local Backpack = Receiver.Backpack
				ReplicatedStorage.Tools:FindFirstChild(Tool):Clone().Parent = Backpack
			end
        end
	end)
end)