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

Why won't this script find the player's character?

Assuming p ends up ultimately becoming the player, why won't this script find the appropriate player's character and do the appropriate effects to them?

        func = function( p ) -- functions go HERE
            print(p.Name .. " GOT REKT")
		local playername = p.Name
		local Character = game.Workspace:FindFirstChild(playername)
		local farasound = game.ServerStorage.LOL:Clone()
		farasound.Parent = Character.Torso
		Character.Torso.Velocity = Vector3.new(0,879,0)
		end

2 comments

0

is the script returning any errors

0

Nope.

2 answers

Well, you could find the Character of a player using

player.Character

Just adding onto what Volo said.

func = function( p ) -- functions go HERE
print(p.Name .. " GOT REKT")
local Character = p.Character
local farasound = game.ServerStorage.LOL:Clone()
farasound.Parent = Character.Torso
Character.Torso.Velocity = Vector3.new(0,879,0)
end

What you did was you used FindFirstChild to find the Player's name in the Workspace. I'm not entirely sure if that would even work, but I'm assuming it doesn't.

A more efficient method for getting the player's character would be using player.Character.

For more information, refer to this.

1 comment

0

chrono2's solution should work. However if there are multiple objects named playername in the Workspace then it might not get the character.

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