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

Hit function script keep get the error "PlayerScripts is not a valid member of Player"?

So I am trying to get player and then get in to player scripts but doesn't work and idk why here is code:

script.Parent.Touched:Connect(function(hit)
	if(hit.Parent:WaitForChild("Humanoid"))then
		local pplayer = game.Players:GetPlayerFromCharacter(hit.Parent)
		pplayer.PlayerScripts.Open_Close2.Disabled = false
		pplayer.PlayerScripts.Open_Close.Disabled = true
	end
end)

2 answers

Hello, ILiekBigBob!

You can try waiting for the PlayerScripts folder to be a child of the player:

script.Parent.Touched:Connect(function(hit)
    if(hit.Parent:WaitForChild("Humanoid"))then
        local pplayer = game.Players:GetPlayerFromCharacter(hit.Parent)
        pplayer:WaitForChild("PlayerScripts").Open_Close2.Disabled = false
        pplayer:WaitForChild("PlayerScripts").Open_Close.Disabled = true
    end
end)

1 comment

0

Sorry It Didnt Work.

Try this

if game.players:GetPlayerFromCharacter(hit.Parent) then

Instead of

if(hit.Parent:WaitForChild("Humanoid"))then

Or replace WaitForChild by FindFirstChild

2 comments

0

I will try thanks

0

Make sure to put my answer as the answer that solves ur problem if it worked

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