Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by
chrono2 189
7 years ago

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
0
is the script returning any errors patrline5599 150 — 7y
0
Nope. chrono2 189 — 7y

2 answers

Log in to vote
0
Answered by 7 years ago

Well, you could find the Character of a player using

player.Character
Ad
Log in to vote
0
Answered by
Hasburo 150
7 years ago

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.

0
chrono2's solution should work. However if there are multiple objects named `playername` in the Workspace then it might not get the character. Link150 1355 — 7y

Answer this question