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

Need help on getting this script to find a player with the same name as text please? (NOT WORKING)

Asked by
Admin8483 -21
7 years ago
Edited 7 years ago

I have been trying to make a voting system, but I have one problem. When I try to find the player, it doesn't look for the Player's name (What is typed into the box named player) but it instead looks inside the textbox. Code is below:

local playname = script.Parent.Parent.Player.Text
script.Parent.MouseButton1Down:connect(function()
        local value = game.Players:FindFirstChild(playname["leaderstats"]["ThumbsUp"].Value)
        value = value + 1
end
0
Is Player.Text a table formatted as a string? Like a JSON table or something? Also, you should post the returned error code. GShocked 150 — 7y
0
There is no error. It just doesn't work. Admin8483 -21 — 7y

2 answers

Log in to vote
0
Answered by 7 years ago

first off, it's Player.Name, not Player.Text. secondly, why in the world would you use FindFirstChild when you already have the player. just do local value = script.Parent.Parent.Parent.Player["leaderstats"]["ThumbsUp"].Value or if it's in a LocalScript do game.Players.LocalPlayer

0
No, not voting for the player you are playing as. "Player" is the name of the textbox. I just need to know how to target a player by using that text, using the text from it, and not the path to the textbox.(I am voting for another player) Admin8483 -21 — 7y
0
But thanks for an idea. Probably won't work though :( ROBLOX keeps acting weird. Admin8483 -21 — 7y
Ad
Log in to vote
0
Answered by 7 years ago
local playname = script.Parent.Parent.Player.Text
script.Parent.MouseButton1Click:connect(function()
        local value = game.Players:FindFirstChild(playname).leaderstats.ThumbsUp.Value
        value = value + 1
end

Hope this helped if the problem persists, try testing it in player

Also if this is in the StarterGui make sure this is in a local script.

0
ROBLOX IS SO MESSED UP! I HAVE BEEN TRYING TO GET THIS SCRIPT TO WORK FOR 3 DAYS! I HAVE TESTED BOTH ANSWERS IN REAL SERVERS AND STUDIO! IT STILL WONT WORK!!!! PLEASE HELP! Admin8483 -21 — 7y

Answer this question