How can one identify player and character on a server script?

Hello there everyone! I’m here today because I ran into a bit of a problem. I was trying to identify the player and character in a server script that I placed in a tool but in output, it kept saying that it attempted to index nil. How can I fix this?

local Tool = script.Parent
local Handle = Tool.Handle
local Player = game.Players.LocalPlayer

local Form = game.ReplicatedStorage.Transformations.SSJ.Goku.SSJ

local function onEquipped(_mouse)
	Tool.Activated:Connect(function()
		wait(0.5)
		Handle.Material = Enum.Material.Neon
		wait(1)
		Form:Clone()
		Form.Parent = Player:WaitForChild("Backpack")
		
		wait(0.5)
		Tool:Destroy()
	end)
end
Tool.Equipped:Connect(onEquipped)

heres my script

The tool unequipped will be in the Backpack so then the player would be;

Tool.Parent.Parent

But once equipped it would be;

game.Players:GetPlayerFromCharacter(Tool.Parent)

So start off with Tool.Parent.Parent

1 Like

Thanks for the help mate very much appreciated!

1 Like