Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to define a character in a server script?

Hi, I am making an invincibility potion for my game that prevents the player from getting damage using the force field but I have no idea how to parent the forcefield to the character in a server script. This is my script.

local tool = script.Parent
local char = --How to define the character?--

tool.Activated:Connect(function()
	local FF = Instance.new("ForceField", char)
	wait(5)
	FF:Destroy()
end)

Please help me.

1 answer

✓ Accepted answer

It's safe to assume that Tool.Parent refers to the Character Model when Equipped, therefore, it's best to allocate the avatar accordingly:

local Tool = script.Parent


Tool.Equipped:Connect(function()
    Character = Tool.Parent
end)

Tool.Activated:Connect(function()
    print(Character.Name.." used the Tool!")
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.