I am trying to make this local script into a global script, whenever I try to run this script in a global script it does not work. Can someone help me?
TextBox = script.Parent
r1 = script.Parent.Parent.Room1
r1.BackgroundColor3 = BrickColor.new("Mint").Color
local room1 = game:GetService("ReplicatedStorage"):WaitForChild("Room1")
hasTouched = false
TextBox:GetPropertyChangedSignal("Text"):Connect(function()
r1.MouseButton1Click:Connect(function()
if hasTouched == false then
hasTouched = true
local text = TextBox.Text
r1.BackgroundColor3 = BrickColor.new("Persimmon").Color
room1:Clone().Parent = game.Players:WaitForChild(text).Backpack
print("Gave room 1 to ",text)
end
end)
end)
local Players = game:GetService("Players")
game.Players.PlayerRemoving:Connect(function(player)
local backp = player:WaitForChild("Backpack")
local room1 = backp:WaitForChild("Room1")
if room1 then
print("Removed room 1 from backpack")
hasTouched = false
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local rom1 = game.Workspace:WaitForChild(player.Name)
local romm1 = rom1:WaitForChild("Room1")
if romm1 then
print("Removed room 1 from hotbar")
hasTouched = false
end
end)
