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

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

Asked by 3 years ago

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

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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)
Ad

Answer this question