Problem with tool actiavtion

Greetings, I want a tool when activated to make the player chat.
The issue is whenever I try it it is index nil.
I tried changing the code but it still doesn’t work, I haven’t found any solutions for the problem.
The error code it displays is: Workspace.Paper.Handle.Script:2: attempt to index nil with ‘Character’
Code:

script.Parent.Parent.Activated:Connect(function(A)
	local Char = A.Character
	local Chat = game:GetService("Chat")
	Chat:Chat(Char.Head, "Secret documents???", 1)
end)

Thank you for your help!

The argument “A” you have there will return nil, as there is no arguments that gets passed through when using the event “Activated”.

Therefore, you’re trying to get nil.Character, which is why you get an error. Instead, use this:

local Player = game:GetService("Players").LocalPlayer

script.Parent.Parent.Activated:Connect(function(A)
	local Char = Player.Character or Player.CharacterAdded:Wait()
	local Chat = game:GetService("Chat")
	Chat:Chat(Char.Head, "Secret documents???", 1)
end)

Hope this helped!

Alright, tho the script Is not local, is there a way of using it in a server script?
Anyways, thank you for the response!
I will try to use it

This means that A does not exist, check if the variable is correct.

From quickly brainstorming (not exactly testing), I could guess that it might be possible to make tools activated from a server script. However, this would take a whole other system and would be way too complicated.

Simply use a Local Script and do what I previously said.

local Player = game:GetService("Players").LocalPlayer

script.Parent.Parent.Activated:Connect(function(A)
	local Char = Player.Character or Player.CharacterAdded:Wait()
	local Chat = game:GetService("Chat")
	Chat:Chat(Char.Head, "Secret documents???", 1)
end)

As far as I’m concerned, there is no reason at all to be equipping a tool from a Server Script.

Alright then, anyways thank you!