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

Plr is not a valid member of Players?

script.Parent.Catch.Touched:connect(function(otherPart)
	print(otherPart)
	local plr = script.Parent.Parent.Parent.OwnerName.Value
	local turninprice = otherPart.Parent.turninprice.Value 
		if otherPart.Parent.Parent == script.Parent.Parent.Parent.MoneyBricks then 
			otherPart:Destroy()
			print ("Part deleted")
			print (plr)
			game.Players.plr.leaderstats.Money.Value=plr.leaderstats.Money.Value+turninprice
	end
	end)

08:31:27.072 - plr is not a valid member of Players 08:31:27.072 - Script 'Workspace.Tycoon.ConveyorLine1.Catcher.Catcher', Line 9

This is the error I receive when the script is trying to work, I've established the variable as plr, and even when it prints "plr" it prints Player1, however when I try to call the variable on line 9, it doesn't establish that game.Players.plr is supposed to mean game.Players.player1 (or whoever's name is on the OwnerName value)

Any help would be appreciated, thanks!

2 answers

✓ Accepted answer

Your issue is that you are trying to access the property/member of game.Players called plr. However, that doesn't exist. You need to replace this:

game.Players.plr.leaderstats.Money.Value=plr.leaderstats.Money.Value+turninprice

with this:

game.Players[plr].leaderstats.Money.Value=plr.leaderstats.Money.Value+turninprice

That way, you're instead accessing the member with the name contained in the variable plr.

Your trying to find 'plr' inside players The children of game.Players are the people in the game.

local player = gamer.Player:FindFirstChild("plr")
if player then
player.leaderstats.Money.Value=plr.leaderstats.Money.Value+t
end

1 comment

0

If I modify my script with what you said, I receive the error, "09:57:59.343 - Player is not a valid member of DataModel" and the leaderstats are not added

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