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

How do I make a gui inserted when a player walks over an object?

My position settings say the gui should not be on the screen and I want it like that but whenever I play the game the gui doesn't show up as a new text button in the starter gui Help.~~~~~~~~~~~~~~~~~ game.Workspace.Hill1.NamePlate.Touched:Connect(function(player) if player.claim == false then if game.Workspace.Hill1.Claimed.Value == false then local claim = Instance.new("TextButton", game.StarterGui.ScreenGui) claim.Position = UDim2.new(0.408, 0,0, -100)

	end
	
	
	
end

end)


2 answers

✓ Accepted answer

You have a lot of problems with your script but I'm just gonna fix the main ones for you.

workspace.Hill1.NamePlate.Touched:Connect(function(hit)
	local player = game:GetService('Players'):GetPlayerFromCharacter(hit.Parent)
	if player ~= nil and player.claim.Value == false then
		if game.Workspace.Hill1.Claimed.Value == false then
			local claim = Instance.new("TextButton", player.PlayerGui.ScreenGui)
			claim.Position = UDim2.new(0.408, 0,0, -100) 
		end
	end
end)

First off .Touched passes whatever object touched it as an argument, not the player, so I just fixed that to actually get the player. You also were doing parenting the TextButton to StarterGui instead of the actual PlayerGui.

Hope this fixed your problem!

3 comments

0

Hi umm It doesn't seem to be working whenever I touch the block... I haven't editied anything before this response. I also tested you script with a local script and a normal script but none seem to be working also, Do you mind explaining a bit further about the GetPlayerFromCharacter and how i works I am fairly new to lua so I don't know much

0

Hi also one more thing, do you mind viewing my other question arrow to destination please? a million thx

0

Nvr mind it works looking in the wrong place :P thx. Please consider looking at the other question please thx.

Sorry Here is how the code block should look like

game.Workspace.Hill1.NamePlate.Touched:Connect(function(player)
	if player.claim == false then
		if game.Workspace.Hill1.Claimed.Value == false then
			local claim = Instance.new("TextButton", game.StarterGui.ScreenGui)
			claim.Position = UDim2.new(0.408, 0,0, -100) 
			
		end
		
		
		
	end
		
end)

that block of code was in a local script Here is the script to insert the boolean value into the player (which works) it is a normal script

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