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

How would i make this a keydown script? So that when i press a key it activates.

Asked by
exarlus 72
6 years ago
wait(.1)
--[[
    A note from script:
    If you decide to take this script, make sure you take the module as well. It's in workspace.
    This won't work unless this script is a LocalScript in StarterGui/StarterPack and the modulescript is in workspace.
    I hope you enjoy the script and the modulescript attached to it. In the video I have showed you how to add your 
    own effects and such. All you need is the chatted event and then the module functions
    To add aura and hat use SSJAura() and SSJHat()
    Thanks for using my script
    --script_ing
--]]
local mod = require(workspace.SSJModule)
local TransformationAnims = mod.TransformationAnims
local ScreenAnims = mod.ScreenAnims
local p = game.Players.LocalPlayer
--[[
    Module functions:
    TransformationAnims.SphereExplosion()
    TransformationAnims.CylinderExplosion()
    TransformationAnims.RingExplosion()
    ScreenAnims.FlashScreen()
    mod:ChatFunction(msg) --the msg argument IS ALWAYS A STRING
--]]
function SSJAura()
    local tor = p.Character.Humanoid.RigType == "R6" and p.Character.Torso or p.Character.UpperTorso
    local particle = script.ParticleEmitter:Clone()
    particle.Parent = tor
end
function SSJHat()
    mod:ClearHats()
    local hair = script.Hat:Clone()
    hair.Parent = p.Character
end
--so this is how you use it:
--First let's get the chatted event
p.Chatted:connect(function(msg) --when the player chats
    if msg == "ssj" then --if what the player chatted is "ssj" then execute this:
        for i = 1, 5 do --for 5 times do this:
        ScreenAnims.FlashScreen() --Flashes your screen yellow
        wait()
        end
        mod:ChatFunction("AHHH!") --Make the player say AHHH!
        for i = 1, 20 do
            coroutine.resume(coroutine.create(function() TransformationAnims.RingExplosion() end))
            wait()
        end
        for xD = 1, 5 do
            spawn(function()
                TransformationAnims.SphereExplosion()
            end)
            wait()
        end
        ScreenAnims.FlashScreen()
        mod:ChatFunction("I'm going to DESTROY YOU!!!") --Make em say that
        SSJAura()
        SSJHat() --Now let's add loops and coolness :)
    end
end) --that's about it for the tutorial, you can always turn your graphics up to 10 and make it glow
--my pc is trash so it's gonna lag but i'll show u

1 answer

Log in to vote
0
Answered by
Scaii_0 145
6 years ago

You would need to do this for a key pressed function

function onKeyPress(inputObject, gameProcessedEvent) --Function
    if inputObject.KeyCode == Enum.KeyCode.R then --What key you want to be pressed
        print("R was pressed") --Put the rest of the script here (what you want to do)
    end
end

game:GetService("UserInputService").InputBegan:connect(onKeyPress) -- Make sure you have this at the end, else it wont work

Of course for more in-depth explanations you could check out the roblox wiki. There are even the scripting books on the page.

Ad

Answer this question