I have got a script which gets the name of the person who touched that part, however, I need that name in a different script. How can I do this? Thanks
If you mean by sharing variables with other scripts use the Global function or _.G
, example.
-- script one. _G.string="string" -- script two. print(_G.string)
Try a StringValue object.
--Script 1, named "Script1", located in a part, with a StringValue object called "name" script.Parent.Touched:connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then script.name.Value = player.Name script.Parent.Script2.Disabled = false end end)
--Script 2, named "Script2", disabled by default, also located in the part print(script.Parent.Script1.name.Value)
Global variables (those located in _G) also work, but you want to avoid using them in most cases.