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

Loading GUI only works for the first player?

So... I added this local script into the starterGui so when a player touches a part, he will be shown a loadingGui and will be teleported to another place.

However... I recently noticed that this loadingGui only works for the first player who touches the part, and not for the others. Could somebody help me?

local debounce = false

function onTouched(hit)
    if game.Players:FindFirstChild(hit.Parent.Name) and debounce == false then
        debounce = true
        local player = game.Players[hit.Parent.Name]
		local rot = 0
		player.PlayerGui.RevolutionGUI.ImageLabel.Visible = true
        while true do
			for i = 1,12 do
				player.PlayerGui.RevolutionGUI.ImageLabel.Loading.Rotation = rot
				rot = rot + 30
				wait()
			end	
		end
        debounce = false
    end
end

script:Destroy()

game.Workspace.RevolutionTP.Touched:connect(onTouched)

(The Rotation is to make a circle rotate on the loading screen.

1 comment

0

It's because you're using script:Destroy() at the end

1 answer

✓ Accepted answer

1: You could manually create a GUI whenever someone touches the brick. Example (because I don't know your specific dimensions, I'm just gonna do something random):

local debounce = false
function onTouched(hit)
	if game.Players:FindFirstChild(hit.Parent.Name) and debounce == false then
		local player = game.Players:FindFirstChild(hit.Parent.Name)
		local nameguihere = Instance.new("ScreenGui") -- You can rename the gui variable
		namegui.Parent = player:WaitForChild("PlayerGui")
		namegui.Name = "" -- Rename the gui here
		local renameimage = Instance.new("ImageLabel")
		renameimage.Parent = namegui -- Rename everything that says "namegui" to whatever you rename the variable to
		renameimage.Size = UDim2.new(0,200,0,50) -- Change size to your liking 
		renameimage.Visible = true
		local textlabel = Instance.new("TextLabel")
		textlabel.Parent = renameimage
		textlabel.Size = UDim2.new(0, 200, 0, 50)
		local rot = 0
		while true do
			for i = 1, 12 do
				textlabel.Rotation = rot
				rot = rot + 30
			end
		end
	end
end
script.Parent.Touched:Connect(onTouched) -- As you can see I didn't use "script:Destroy() because this is one of the reason it doesn't work, and :connect is deprecated"

I hope this helps, I wrote this off the top of my head, but I'm pretty sure this will work.

2 comments

0

Thanks a lot with helping me out! With some customization of the imagelabel, it works! Awesome ^w^

0

Np :D

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