So, I'm making a script and I made a function that is called by :MouseButton1Click() so in the function I made the parameters "plr" and in the function I made this line "if plr.Parent.Parent.PlayerHasBase.Value == false then" and it doesn't work, because the output says plr = nil so then I need help, how do I get the player from a click? Because my way doesn't work.... :c Full script:

function SpawnBase(plr)
	if plr.Parent.Parent.PlayerHasBase.Value == false then
		local Base = game.ServerStorage.Base:Clone()
		Base.Parent = plr.Character
		Base:MoveTo(game.Workspace.Spawn1.Position)
	end
end

script.Parent.MouseButton1Click:connect(SpawnBase)

8 comments

0

If possible, use a LocalScript and define plr as game.Players.LocalPlayer

0

It says in the output "19:37:25.263 - PlayerHasBase is not a valid member of DataModel" If I do that....

0

If it is a local script then player.Parent.Parent is "game"

1

Tempestatem is right, idk what you are searching for, 3 layers above the player, that doesn't make sense, can you elaborate a bit more what PlayerHasBase is and where it is located?

0

Oh, forgot to change that when I used LocalPlayer.....

0

Did that fix your problem lucas4114?

0

Yup.....

0

bruh just use local plr = game.Players.LocalPlayer