Simulator Ui Effects?

Hello my name is Crills1! I’m new to the Developer Forum and I’m here to interact with others and learn! So my main problem is not knowing the name to this Simulator Ui Effect and not knowing where I could even start my research. This had been a problem for MONTHS and have found nothing. I tried using Google and Youtube and no solutions. If I can have some help that would be ABSOLUTELY AMAZING!
Effect3 Effect1 Effect2

15 Likes

I’ve been trying to look for the same information! Please let me know if you figure it out.

Hopefully I will soon. But this just seems impossible to figure out.

Using that code, you could move the stuff to what it returned

local r = Random.new()

local function GetRandomPosition()
    return UDim2.new(r:NextNumber(0,1),0,r:NextNumber(0,1),0)
end
guiObject.Positon = GetRandomPosition()
3 Likes

I wrote this in about 10 minutes, but this is the basic idea. When the player clicks a button, clone the asset that you want, and do some simple math to tween it.

local Player = game.Players.LocalPlayer
local Picture = script.Parent.ImageLabel
local Button = workspace.Button

local TweenService = game:GetService("TweenService")


Button.ClickDetector.MouseClick:Connect(function()
	-- Clone the asset
	local pt = Picture:Clone()
	pt.Parent = script.Parent
	-- Place it below the screen. The random will add some variation
	pt.Position = UDim2.new(.45 + math.random(10)/100, 0, 1, 0)
	
	-- Tween the asset into place
	local info = TweenInfo.new(1)
	TweenService:Create(pt, info, {Position = pt.Position - UDim2.new(0, 0, .25 + math.random(50)/100, 0)}):Play() -- position
	TweenService:Create(pt, info, {ImageTransparency = 1}):Play() -- transparency
end)

Here’s it working: https://gyazo.com/7259e402c882a4f3c4d88dc3d57d113c

Hope this helps!

4 Likes

Does this code only work on bricks? I’m looking for where if you click wherever this will pop up.

This will now run every single time the player clicks, even if they’re clicking a UI or something. You can add some checks so it won’t run when UI is open.

local Mouse = Player:GetMouse()
local Picture = script.Parent.ImageLabel

local TweenService = game:GetService("TweenService")
local UserInputService = game:GetService("UserInputService")


UserInputService.InputBegan:Connect(function(input)
	local inputType = input.UserInputType
   	if inputType == Enum.UserInputType.MouseButton1 then
		-- Clone the asset
		local pt = Picture:Clone()
		pt.Parent = script.Parent
		-- Place asset at mouse position
		pt.Position = UDim2.new(0, Mouse.X, 0, Mouse.Y)
		
		
		-- Tween the asset into place
		local info = TweenInfo.new(1)
		TweenService:Create(pt, info, {Position = pt.Position - UDim2.new(0, 0, .25 + math.random(50)/100, 0)}):Play() -- position
		TweenService:Create(pt, info, {ImageTransparency = 1}):Play() -- transparency
		
		-- Destroy asset when invisible
		wait(1)
		pt:Destroy()
	end
end)
2 Likes

For some reason it is not detecting my clicks? I’m obviously doing something wrong. I put the brick in workspace with a localscript and put a Image label in a ScreenGui in StartGui. Its not saying any errors in my Output.

1 Like

Mind telling me where you set all of these parts? @MayorGnarwhal

This took forever to write so please read it thoroughly!

Try to break this up into multiple things you want to accomplish.

  1. You want a copy of the UI to be given to the player.
  2. You want to place it on a random point on the screen.
  3. You want to destroy it after a few seconds.

I’m guessing you want all these steps to happen whenever someone clicks a button. To do this, you’d have to make a function run whenever the MouseButton1Click event is fired, like this:

YourButton.MouseButton1Click:Connect(function()
 
--The steps here

end)

You should keep the gui somewhere other than StarterGui, ReplicatedStorage is a good place.

1. You want a copy of the UI to be given to the player.

There is a method called Clone that returns a clone of the object you called it on. Example:

local Gui = game.ReplicatedStorage.Gui
local NewGui = Gui:Clone()
print( "A clone of Gui was created!") 

Now that we can create a copy of the Gui, we have to give that copy to the player so the player can see it. Before we do that though, we have to learn about the PlayerGui.

The PlayerGui is a folder that each player has. All the guis that the player sees are in his/her playergui. You should test this out yourself, playtest in studio and you will notice your player is added to the Players folder, inside your player is your PlayerGui with all your Guis in it. Now that we know how to give a clone of the gui to the player, we can start off on the code.

--//THIS SCRIPT NEEDS TO BE A LOCAL SCRIPT!!
local Button = --Path to your button
local Gui = --Path to the gui that will pop up.
local Player = game.Players.LocalPlayer --THIS LINE WILL ONLY WORK IN A LOCAL SCRIPT!!

Button.MouseButton1Click:Connect(function()

    --//Step 1
    local NewGui = Gui:Clone()
    NewGui.Parent = Player.PlayerGui

    --//Step 2

end)

2. You want to place it on a random point on the screen.

If you notice when you position a UI, there are four numbers.
First number: X scale
Second number: X offset
Third number: Y scale
Fourth number: Y offset

Difference between scale and offset:

Offset:
The amount of pixels the UI is offset from the origin point. The origin point is at the top left corner of the screen, so if your UI’s X offset would be 10, and your Y’s offset would be 20, it would be ten studs from the left of the screen, and ten studs from the top of the screen.

Scale:
Scale doesn’t go by pixels, it goes by percentage of how big the screen is. Let’s say your screen is 1000 pixels wide, and your UI’s X scale is 0.5, it would move 500 pixels along the X Axis. Let’s say your UI’s X scale is 1, it would move 1000 pixels across the screen and would be basically on the other side of the screen.

We’re gonna position the UI somewhere between 0 and 1 on the scale X and Y axis. But how are we gonna generate a random number between 0 and 1, you may ask? We can use math.Random for that. Here’s an example of how it works:

local RandomNumber = math.Random(1, 5) 
print(RandomNumber) --Would print a random number between 1 and 5

Here’s what we’ve got so far:

--//THIS SCRIPT NEEDS TO BE A LOCAL SCRIPT!!
local Button = --Path to your button
local Gui = --Path to the gui that will pop up.
local Player = game.Players.LocalPlayer --THIS LINE WILL ONLY WORK IN A LOCAL SCRIPT!

Button.MouseButton1Click:Connect(function()

    --//Step 1
    local NewGui = Gui:Clone()
    NewGui.Parent = Player.PlayerGui

    --//Step 2
    XPos = math.Random(0, 1)
    YPos = math.Random(0, 1)
    NewGui.ImageLabel.Position = UDim2.new(XPos, 0, YPos, 0)
    -- Change ImageLabel to the name of your Image or textbox in the gui.

end)

3. You want to destroy it after a few seconds.

This is definitely the easiest step, there’s a method called Destroy that destroys the object it’s called on. Pretty sure you don’t need an example to understand that.

Wait(number) waits the number of seconds in the parenthesis before continuing on with the script.

The finished Product:

--//THIS SCRIPT NEEDS TO BE A LOCAL SCRIPT!!
local Button = --Path to your button
local Gui = --Path to the gui that will pop up.
local Player = game.Players.LocalPlayer --THIS LINE WILL ONLY WORK IN A LOCAL SCRIPT!

Button.MouseButton1Click:Connect(function()

    --//Step 1
    local NewGui = Gui:Clone()
    NewGui.Parent = Player.PlayerGui

    --//Step 2
    XPos = math.Random(0, 1)
    YPos = math.Random(0, 1)
    NewGui.ImageLabel.Position = UDim2.new(XPos, 0, YPos, 0)
    -- Change ImageLabel to the name of your Image or textbox in the gui.

    --//Step 3
    wait(2) --Change 2 to how long you want it to last.
    NewGui:Destroy()
end)
13 Likes

The second script I sent doesn’t require the Button, but this is it.

image

Remember, the code I gave you is very basic, so you must modify it to make it look prettier.

If you’re still confused, I would recommend reading @C0lvy123’s response because it is incredibly thorough.

This whole thing from both of you just blew my mind and made everything more simpler. @C0lvy123 response was just so clear to me. @MayorGnarwhal yours made sense a lot after I was done reading his response. Thank you so much for helping me!!

2 Likes

Hello, I just got the solution to both of our problems. Feel free to check the responses I responded too.

1 Like

you can use tweens and events to make that. @TriipXX