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

How do I make a GUI shake when I press a certain key?

I tried to make a gui shake. For some reason it only goes to 1 position and stops. Anyone know what I did wrong?

local shaketime = 0
local shakeconditions = math.random(1,20)
local Mouse = Player:GetMouse()
local GUI = game.Players.LocalPlayer.PlayerGui.Test
Mouse.KeyDown:Connect(function(key)
	if key == "e" then

repeat
			wait(0.3)
			GUI.Frame.Position = UDim2.new(0, shakeconditions, 0, shakeconditions)
			shaketime+=1
wait()
		until shaketime == 15

thanks in advance.

1 answer

Using CameraOffset is primitive to use so for you i'd say you need CameraOffset, should be simple for you to learn.

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()

UIS.InputBegan:Connect(function(Key)
	if Key.KeyCode == Enum.KeyCode.E then
		for i = 1,90 then
			wait(0.01)
			char.Humanoid.CameraOffset = Vector3.new(math.random(-2,2),math.random(-2,2))
		end

		char.Humanoid.CameraOffset = Vector3.new(0,0,0)

	end
end)

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