Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
Edited 4 years ago

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)


0
I changed the script and it still doesn't do anything, including the print. Citybuild122 0 — 4y
0
I'm not really sure why it happens. Try restarting ROBLOX Studio or your computer. It might be a bug skate992 57 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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.

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? Citybuild122 0 — 4y
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. davidgingerich 603 — 4y
Ad

Answer this question