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

Why cant my Shop script locate the Value of the Price?

my player is defind here since i couldnt figure out how to find local player in a normal script

game.Players.PlayerAdded:Connect(function(player)
	local price = player.PlayerGui:WaitForChild("Gui").Main.Info.Price
	local leaderstats = player:FindFirstChild("leaderstats")
	local Cash = leaderstats:FindFirstChild("Cash")

	if Cash.Value >= price.Value then
	Cash.Value = Cash.Value - price.Value

The "price" is a intValue. When I did

local price = 100

it worked. But when i changed it back to

local price = player.PlayerGui:WaitForChild("Gui").Main.Info.Price

it didnt work. This is all in a normal script in workspace. Can someone explain why my script cant find the value of the "price" The "price" is located in the Gui

1 comment

0

Is the ouput saying something like cannot locate an object

1 answer

✓ Accepted answer

Servers don't usually have access to anything in a player's PlayerGui, so when you say WaitForChild("Gui"), it will never be found.

Further, since you're trying to use GUI, you should be using a LocalScript (since server scripts don't have access to the GUI). You can refer to the local player with game.Players.LocalPlayer.

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