Basically i want the script to activate when you press a certain button instead of saying something in the chat to activate it.
anim=Instance.new("Animation",workspace) anim.AnimationId = "http://www.roblox.com/Asset?ID=293536378" jun = script.Parent.Parent Stuff = false local sp = script.Parent local s = Instance.new("Sound") s.SoundId = "http://www.roblox.com/asset/?id=213733166" s.Volume = 3 s.Looped = true s.PlayOnRemove = false s.Parent = sp --password function ssj() s:Play() game:GetService("Chat"):Chat(jun.Character.Head,"NOOOO!!!",Enum.ChatColor.Red) game:GetService("Chat"):Chat(jun.Character.Head,"YOU'LL PAY FOR THIS!!!",Enum.ChatColor.Red) game:GetService("Chat"):Chat(jun.Character.Head,"YOU WILL PAY FOR THIS!!!",Enum.ChatColor.Red) for loop = 1,50 do delay(0,function() local x = Instance.new("Part") game.Debris:AddItem(x, 3) x.CanCollide = false x.Anchored = true x.Size = Vector3.new(1,1,1) x.Material = "Neon" x.TopSurface = "Smooth" x.BottomSurface = "Smooth" x.Parent = game.Workspace x.CFrame = jun.Character.Torso.CFrame x.BrickColor = BrickColor.new("Bright blue") local m1 = Instance.new("BlockMesh", x) delay(0,function() for loop = 1,20 do m1.Scale = m1.Scale + Vector3.new(1,1,1) x.CFrame = x.CFrame * CFrame.Angles(0.2,0.2,0.2) x.Transparency = x.Transparency + 0.05 wait() end end) end) delay(0,function() local x = Instance.new("Part") game.Debris:AddItem(x, 4) x.Size = Vector3.new(1,1,1) x.CanCollide = false x.Anchored = true x.CFrame = jun.Character.Torso.CFrame * CFrame.new(0,-2.5,0) x.TopSurface = "Smooth" x.BottomSurface = "Smooth" x.BrickColor = BrickColor.new("Bright blue") x.Parent = game.Workspace local m1 = Instance.new("SpecialMesh", x) m1.MeshId = "http://www.roblox.com/asset/?id=20329976" delay(0,function() for loop = 1,100 do m1.Scale = m1.Scale + Vector3.new(1,0.1,1) x.Transparency = x.Transparency + 0.02 x.CFrame = x.CFrame * CFrame.Angles(0,1,0) wait() end end) end) wait(0.1) end game:GetService("Chat"):Chat(jun.Character.Head,"FOR ALL THOSE PEOPLE YOU SLAUGHTERED",Enum.ChatColor.Red) game:GetService("Chat"):Chat(jun.Character.Head,"YOU WILL PAY",Enum.ChatColor.Red) if Stuff == false then Stuff = true for u, c in pairs (jun.Character:GetChildren()) do if c.className == "Hat" and c.Name ~= "Swordpack" and c.Name ~= "GlassesBlackFrame" then c.Handle.Transparency = 1 end end local Hair4 = game.ReplicatedStorage.SSJGSSJ:Clone() Hair4.Parent = jun.Character Hair4.Name = "Hair" Hair4.CanCollide = false Hair4.Locked = true Hair4.CFrame = jun.Character.Torso.CFrame local Weld = Instance.new("Weld") Weld.Parent = jun.Character.Head Weld.Part0 = jun.Character.Head Weld.Part1 = Hair4 Weld.C0 = CFrame.new(0, .8, 0.11) * CFrame.Angles(0,math.pi,0) if jun.Character.Torso:findFirstChild("PwnFire") == nil then local animTrack = jun.Character.Humanoid:LoadAnimation(anim) animTrack:Play() wait() local fr = game.lighting.ParticleEmitterd:clone() fr.Parent = jun.Character.Torso end game:GetService("Chat"):Chat(jun.Character.Head,"I....",Enum.ChatColor.Red) game:GetService("Chat"):Chat(jun.Character.Head,"SSJGSSJ!!!!!!!!!!!!!!",Enum.ChatColor.Red) if jun.Character.Torso:findFirstChild("PwnSparkles") == nil then local cr = game.lighting.ParticleEmitterd0:clone() cr.Parent = jun.Character.Torso local br = game.lighting.ParticleEmitterd1:clone() br.Parent = jun.Character.Torso end jun.Character.Humanoid.MaxHealth = 1e+8 wait(0.3) jun.Character.Humanoid.Health = 1e+8 end end function nossj() if Stuff == true then Stuff = false if jun.Character.Torso:findFirstChild("ParticleEmitter150")~=nil then jun.Character.Torso:findFirstChild("ParticleEmitter150"):Remove() end if jun.Character.Torso:findFirstChild("ParticleEmitter1500")~=nil then jun.Character.Torso:findFirstChild("ParticleEmitter1500"):Remove() end if jun.Character.Torso:findFirstChild("ParticleEmitter15000")~=nil then jun.Character.Torso:findFirstChild("ParticleEmitter15000"):Remove() end game:GetService("Chat"):Chat(jun.Character.Head,"Wow",Enum.ChatColor.Green) game:GetService("Chat"):Chat(jun.Character.Head,"hhahaha",Enum.ChatColor.Green) local p = Instance.new("Part") p.Parent = jun.Character p.Anchored = true p.CanCollide = false p.Transparency = 0.1 p.formFactor = "Symmetric" p.Size = Vector3.new(22, 22, 22) p.TopSurface = "Smooth" p.BottomSurface = "Smooth" p.Name = "Sharingan" p.Shape = "Ball" p.CFrame = jun.Character.Torso.CFrame p.BrickColor = BrickColor.new("New Yeller") for i = 1 , 10 do wait(0.05) p.Size = p.Size + Vector3.new(-4, -4, -4) p.Transparency = p.Transparency + 0.1 p.CFrame = jun.Character.Torso.CFrame end s.Volume = 0 p:Remove() for u, c in pairs (jun.Character:GetChildren()) do if c.className == "Hat" and c.Name ~= "Swordpack" and c.Name ~= "GlassesBlackFrame" then c.Handle.Transparency = 0 end if c.Name == "Hair" then c:Remove() end end jun.Character.Humanoid.Health = 100 wait(0.3) jun.Character.Humanoid.MaxHealth = 100 end end jun.Chatted:connect(function(Msg) local msg = Msg:lower() if string.sub(msg, 1, 7) == "super saiyan god super saiyan super" then wait(0.1) ssj() end if string.sub(msg, 1, 13) == "ssjb" then wait(0.1) ssj() end if string.sub(msg, 1, 6) == "!" then wait(0.1) ssj() end if string.sub(msg, 1, 10) == "calm" then wait(0.1) nossj() end if string.sub(msg, 1, 3) == "off" then wait(0.1) nossj() end end) function OnDeath() wait() nossj() end jun.Character.Humanoid.Died:connect(OnDeath) jun = script.Parent.Parent Stuff = false --mediafire---
Use UserInputService!! You could also use ContextActionService, allowing for better cross-platform usage but I like UserInputService due to its simplicity. I'll give an example of a script that needs to fire when F is pressed:
local uis = game:GetService("UserInputService") local detectFkey = function(input) if input == enum.Keycode.F then return true else return false end end local coreButtonScript = function(userInput, gameProcessedEvent)--more on this later if detectFkey(userInput.keycode) and not gameProcessedEvent then print("F has been pressed!") end end uis.InputBegan:connect(coreButtonScript)
This script will print a string when F is pressed. You may wonder about gameProcessedEvent though.. This parameter will return true if the game processed the event! Make sense? No? ;( If the player clicks f in chat, user input service will still fire, but gameProcessedEvent will return true. Otherwise, in normal gameplay it will return false? Get it now? Whenever the game uses the input, gameProcessedEvent will return true, so we don't do the function. Hope I helped! Lemme know!