I'm creating a game, and I have a StringValue that detects who it belongs to. That works fine, but I try to locate the player based on that value, and it doesn't work. I don't know how to do this, and here is my failed attempt:
while 2 > 1 do script.Parent.Name = game.Players[script.Parent.Owner.Value].PlayerGui.Rename.Gui.Name.Value wait (0.5) end
Use the Changed
event and connect it to a function instead of making a loop.
Also, the ObjectValue has already linked the instances from game
, so you can just keep linking from there.
Here is the edited script:
script.Parent.Owner.Changed:connect(function() local player = script.Parent.Owner.Value if player ~= nil then --Makes sure the value is not nil, or else the script will crash/error! script.Parent.Name = player.PlayerGui.Rename.Gui.Name.Value end end)
If you have any problems, please leave a comment below. Thank you and I hope this will help you!
Locked by EzraNehemiah_TF2, Link150, and Azmidium
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?