Help with "Workspace" Button

Hello, I am KDBgames and I need your help.

I was scripting a Buy button to buy a house. But, not in the GUI. I want it in the Workspace. So I started scripting. I first tryed a “LocalScript”. But I saw that that do not worked. So I tryed the same script in a normal “Script”. And it worked!

But the problem is. I can’t find the “player”. You can see what I have in the screens/codes:

-- This is the code for the "Script" in the button.
local player = game.Players.LocalPlayer
local Parent = script.Parent.Parent.Parent.Parent.Parent.Parent

	if Parent.Owner.Value == "" then
		Parent.Owner.Value = player.Name
		Parent.Using.Value = true
		player.leaderstats.Money.Value = player.leaderstats.Money.Value - Parent.Price.Value
		if player.Name == Parent.Owner.Value then
			Parent.Owner.Value = ""
			Parent.Using.Value = false
			player.leaderstats.Money.Value = player.leaderstats.Money.Value + (Parent.Price.Value / 2)
-- This is what I get back.
  11:04:20.566 - Workspace.Test House Scripts.BuyBoard.Board.SurfaceGui.Frame.BuyButton.Script:9: attempt to index nil with 'Name'
  11:04:20.569 - Stack Begin
  11:04:20.571 - Script 'Workspace.Test House Scripts.BuyBoard.Board.SurfaceGui.Frame.BuyButton.Script', Line 9
  11:04:20.577 - Stack End

This is the Button in the Workspace:
This is where it is in the Explore:

So the problem is that I can’t find the player.

If you can help me. Please do it! I really need your help!
Thanks for reply.

The SurfaceGui needs to be in PlayerGui in order for it to be interacted with. So put it in StarterGui then set its Adornee to what its original Parent was. This removes the need for a server script (other than for a remote because you will need a remote) as well as the need to type

1 Like

Dat werkt allemaal. Ik heb eigenlijk gewoon hulp nodig om de “Player” te vinden. Kan je daar toevelig mee helpen?

I don’t speak Dutch :grin:

You will just need a RemoteEvent for this, and you can just use LocalPlayer on a local script.

1 Like

Je kunt de “Player” gewoon krijgen als LocalPlayer of op een PlayerAdded-evenement op de server


Sorry. I used translate to for translate it do dutch. But I vergot it to translate it back to english :wink:

and, thanks for help. I try with that remoteevent.

1 Like

thanks! I will try that. With the player added.