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

Local Script is not working in text button to save player's name to a value?

Basically, I have a GUI that will allow a player to choose a name for their car shop. They click the submit button and it saves it. There are two scripts for this. The local script will take the player's name and the name they chose for their shop, and save it to two separate string values. This bypasses having to use server events. A secondary script, will take the values and apply them in DataStore and to a physical sign.

The issue is that the local script is not working. Like, at all. Not even the first line.

	print ("Works")
	local player = game.Players.LocalPlayer
	local Button = script.Parent.Parent:WaitForChild("TextButton")

Button.MouseButton1Click:connect(function(player)
	script.Parent.PlayerName.Value = player.Parent
	script.Parent.Value.Value = script.Parent.Parent.TextBox.Text
end)

Nothing is being printed.

[EDIT] I changed the script to this and it still does nothing.

	print ("Works")
	local player = game.Players.LocalPlayer

function click()
	script.Parent.PlayerName.Value = player.Parent
	script.Parent.Value.Value = script.Parent.Parent.TextBox.Text	
end

script.Parent.MouseButton1Click:connect(click)


2 comments

0

I changed the script and it still doesn't do anything, including the print.

0

I'm not really sure why it happens. Try restarting ROBLOX Studio or your computer. It might be a bug

1 answer

If the first line isn't even printing, then I'm guessing the script itself isn't in the right place. A LocalScript will only run if it's a descendant of PlayerGui, Backpack, PlayerScripts, or the player's character.

2 comments

0

Well, it's inside of a text button, which is inside of a frame, which is inside of a screengui, which is inside of startergui, which then ends up in playergui. So, it should work?

0

If the first line of a script isn't even executing and there's no error, than most likely the script isn't actually being ran, so just make sure it's not disabled and that none of its ancestors are disabled.

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