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

Does anyone know why the gui isn't poping up? Does anyone has a solution?

this is a script in a team and it's a local script. So the GUI is going into the backpack but in a game u have this and it's working? Why isn't it working with me? I want that if a player is sleected that u see the GUI ? Does anyone what is bad?

local active = true
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local down = true
local selection = Instance.new("SelectionBox")
selection.Parent = player.PlayerGui
selection.Color3 = Color3.new(1, 235, 0)

mouse.Move:Connect(function()
	if active == true then
		local target = mouse.Target
		if not target then
			selection.Adornee = nil
		elseif game.Players:GetPlayerFromCharacter(target.Parent) then
			selection.Adornee = target.parent
		else
			selection.Adornee = nil
		end
		
	end
end)

mouse.Button1Down:Connect(function()
	local tar = mouse.Target
	if not game.Players:GetPlayerFromCharacter(tar.Parent) or not tar then
		selection.Adornee = nil
		local player = game.Players:FindFirstChild(tar.Parent)
		script.Parent.Frame.Visible = false
		script.Parent.Main.Visible = false
		active = true
	elseif game.Players:GetPlayerFromCharacter(tar.Parent) then
		active = false
		script.Parent.username.Value = tar.Parent.Name
		script.Parent.Frame.Visible = true
		script.Parent.Main.Visible = true
	end
end)



AnimateEvent = game.ReplicatedStorage.PoliceGui
AnimateEvent.OnClientEvent:Connect(function(arg)
	if script.Parent:FindFirstChild(arg) then
		script.Parent[arg]:TweenPosition(UDim2.new(0, -300, 0.8, -100), Enum.EasingDirection.Out, Enum.EasingStyle.Quad)
	end
end)

4 comments

0

You cant use Instance.new("", Parent) It is deprecated, use selection.Parent

0

What do u mean?

0

He means that the Parent argument is decaperated, so u gotta do the Instance.new("") alone and then set the Parent of the Instance

0

Whatr line?

1 answer

local active = true
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
local down = true
local selection = Instance.new("SelectionBox")
selection.Parent = player.PlayerGui
selection.Color3 = Color3.new(1, 235, 0)

mouse.Move:Connect(function()
    if active == true then
        local target = mouse.Target
        if not target then
            selection.Adornee = nil
        elseif game.Players:GetPlayerFromCharacter(target.Parent) then
            selection.Adornee = target.parent
        else
            selection.Adornee = nil
        end

    end
end)

mouse.Button1Down:Connect(function()
    local tar = mouse.Target
    if not game.Players:GetPlayerFromCharacter(tar.Parent) or not tar then
        selection.Adornee = nil
        local player = game.Players:FindFirstChild(tar.Parent)
        script.Parent.Frame.Visible = false
        script.Parent.Main.Visible = false
        active = true
    elseif game.Players:GetPlayerFromCharacter(tar.Parent) then
        active = false
        script.Parent.username.Value = tar.Parent.Name
        script.Parent.Frame.Visible = true
        script.Parent.Main.Visible = true
    end
end)



AnimateEvent = game.ReplicatedStorage.PoliceGui
AnimateEvent.OnClientEvent:Connect(function(arg)
    if script.Parent:FindFirstChild(arg) then
        script.Parent[arg]:TweenPosition(UDim2.new(0, -300, 0.8, -100), Enum.EasingDirection.Out, Enum.EasingStyle.Quad)
    end
end)

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