Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Clones to the hit.Parent, another player touches it, they get but other loses it, why?

local model = script.Parent
local toucher = model.Detector
local label = model.Display.SurfaceGui.Status
local screen = model.Display
local BillboardGui = Instance.new("BillboardGui")
local Text = Instance.new("TextBox")

local inuse = false

toucher.Touched:Connect(function(hit)
	if game.Players:GetPlayerFromCharacter(hit.Parent) and not inuse and not hit.Parent.Head:FindFirstChildOfClass("BillboardGui") then
		inuse = true
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		for i = 0, 0 do
			label.Text = 'AUTHORIZING'
			label.TextColor3 = Color3.fromRGB(255, 239, 201)
			screen.Warning.PlaybackSpeed = 2.3
			script.Parent.Display.Color = Color3.fromRGB(255, 239, 201)
			model.Glow.Color = Color3.fromRGB(255, 239, 201)
			model.Glow.PointLight.Color = Color3.fromRGB(255, 239, 201)
			screen.Warning:Play()
			wait(0.3)
			label.Visible = false
			wait(0.65)
			label.TextColor3 = Color3.fromRGB(255, 239, 201)
			script.Parent.Display.Color = Color3.fromRGB(255, 239, 201)
			model.Glow.Color = Color3.fromRGB(255, 239, 201)
			model.Glow.PointLight.Color = Color3.fromRGB(255, 239, 201)
			label.Text = 'AUTHORIZING'
			screen.Warning.PlaybackSpeed = 2.3
			screen.Warning:Play()
			wait(0.3)
			label.Visible = false
			wait(0.65)
			screen.Stab:Play()
		end
		wait(1)
			label.Visible = true
			screen.Warning.PlaybackSpeed = 4
			label.TextColor3 = Color3.fromRGB(107, 255, 66)
			script.Parent.Display.Color = Color3.fromRGB(0, 255, 0)
			model.Glow.Color = Color3.fromRGB(0, 255, 0)
			model.Glow.PointLight.Color = Color3.fromRGB(0, 255, 0)
			----GUI
			label.Text = 'NANOCHIP INJECTED'
			BillboardGui.Name = "AuthorizeTag"
			BillboardGui.Parent = hit.Parent:WaitForChild("Head")
			BillboardGui.Active = true
			BillboardGui.Adornee = hit.Parent:WaitForChild("Head")
			BillboardGui.Size = UDim2.new(40, 40, 1, 1)
			BillboardGui.StudsOffset = Vector3.new(0, 3, 0)
			
			Text.Name = "Text"
			Text.Parent = BillboardGui
			Text.BackgroundColor3 = Color3.new(0, 0, 0)
			Text.BackgroundTransparency = 1
			Text.BorderColor3 = Color3.new(0, 0, 0)
			Text.Size = UDim2.new(1, 1, 0.699999988, 0)
			Text.ClearTextOnFocus = false
			Text.Font = Enum.Font.SourceSans
			Text.MultiLine = true
			Text.Text = "AUTHORIZED | " .. hit.Parent.Name
			Text.TextColor3 = Color3.new(0.517647, 1, 0)
			Text.TextScaled = true
			Text.TextSize = 14
			Text.TextStrokeColor3 = Color3.new(1, 1, 1)
			Text.TextWrapped = true
			Text.TextYAlignment = Enum.TextYAlignment.Top
			----GUI
			screen.Warning:Play()
			wait(0.25)
			screen.Warning:Play()
			wait(0.25)
			screen.Warning:Play()
		end
		wait(5)
		inuse = false
	end)

This is used to mark players, but whenever they touch it, a billboard gui gets created which is intended. But if I do it to someone else, the player who touched it before loses the tag, and the new player gets it. What's the problem?

1 answer

✓ Accepted answer

Well, what it seems like is that the adorned of the billboard UI is being set to the player. Try making the GUI instead then when it’s ready to be used. Use a remote event to trigger a local script inside the GUI. And make sure to enable the GUI from the local script

This discussion is preserved as it was. New answers, comments, and votes are closed.