How is this nil! Can you please help?

Hello! I hope you are having a great New Year! I have a pretty big problem. My leveling door won’t work.

What is causing the issue?

Is it Really nil?

No:
image

What is the script so I can help?

script.Parent.Touched:Connect(function(plrhit)
	local plr = game.Players:GetPlayerFromCharacter(plrhit.Parent)
	if plr.LevelsSystem.Level.Value > 30 then 
		script.Parent.CanCollide = true
		wait(3)
		script.Parent.CanCollide = false
	end
end)

Do I need more info?

  1. Normally, the doors collisions are always off unless a player with not the right level touches the door
  2. This door will let anyone go in it, even if they aren’t level 30.

If you can help, please let me know. Thanks, WE

1 Like

Check to make sure it is getting the player properly. I usually use plrhit:FindFirstAncestorOfClass("Model") to get the player’s character, since the .Touched parameter’s direct parent won’t always be the character model (for example, it could hit a child of a hat object).

2 Likes

Ok so quick question. Would I put the model in the brackets (script.Parent)?

You would do:

script.Parent.Touched:Connect(function(plrhit)
	local plr = game.Players:GetPlayerFromCharacter(plrhit:FindFirstAncestorOfClass("Model"))
    if plr then
	    if plr.LevelsSystem.Level.Value > 30 then 
		    script.Parent.CanCollide = true
		    wait(3)
		    script.Parent.CanCollide = false
	    end
    end
end)

But also, may I ask, is this a server or local script? I’m noticing that you are making something uncollidable after having a high enough level, and I have a better solution of doing this.

It is a ServerScript inside of the part.

It would probably taken me an hour to find that out. Thank you for that. Idk why, I keep getting < and > mixed up…

I was planning on having another one of these, but it would be thicker inside the Level 30 area, but it would kill the player.

1 Like

Sorry, not really relevant, but why does your explorer look like that? I like that design, how’d you get it like that?


That is how.