Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Loading GUI only works for the first player?

Asked by 6 years ago

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.

0
It's because you're using script:Destroy() at the end LilHat57 35 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

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.

0
Thanks a lot with helping me out! With some customization of the imagelabel, it works! Awesome ^w^ Dylan011444 59 — 6y
0
Np :D supercoolboy8804 114 — 6y
Ad

Answer this question