I have a script for a sword that I am making. When I click play, the game is stopped and I am given the message, "Character is not a valid member of workspace." Please help me fix the problem and understand what I should do. Here is my script: (the 5th line is highlighted in red.)
local sword = script.Parent
local handle = sword:WaitForChild("Handle")
local event = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
local player = sword.Parent.Parent
local character = player.Character or player.CharacterAdded:wait()

3 comments
Most likely because 'sword.Parent.Parent' is referring to workspace rather than the character model. Double check the directory of the script.
I'd prefer using Player = game...blah blah blah. instead of script.parent
But then how do I know who the player that is using this sword is?