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
If possible, use a LocalScript and define plr as game.Players.LocalPlayer
It says in the output "19:37:25.263 - PlayerHasBase is not a valid member of DataModel" If I do that....
If it is a local script then player.Parent.Parent is "game"
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?
Oh, forgot to change that when I used LocalPlayer.....
Did that fix your problem lucas4114?
Yup.....
bruh just use local plr = game.Players.LocalPlayer