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

Time Stop:GunGame How to use Kaycode to change the size?

Asked by 2 years ago
Edited 2 years ago

I am creating a Time stop game but I need to use key code my script is currently:

local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local hum = plr.Character:WaitForChild("Humanoid")

UIS.InputBegan:Connect(function(input, gameProcessed)
    if input.UserInputType == Enum.UserInputType.Keyboard then
        print("Key:",input.KeyCode)
        wait(1)
        if input.UserInputType == Enum.KeyCode.T then

        print("T was pressed at", input.Position)
        local Timestop = workspace:WaitForChild("Timestop")

        repeat  

            Timestop.Size = Vector3(Timestop.Size+1, Timestop.Size+1, Timestop.Size+1)
            wait(0.1)

        until Timestop.Size == Vector3(190, 190, 190)

    end
    wait(60)

    end
end)

and I have it in Starter Character Scripts

The only output I am getting is ? Key: Enum.KeyCode.T - Client - LocalScript:7

Any help?

0
Hi can you put the rest of your code in a code block. Some of it is already, but can you put the rest in one. theking66hayday 841 — 2y
0
I dont know how to wasdupup 12 — 2y
0
done wasdupup 12 — 2y
0
Hope my answer works for you! C1RAXY 81 — 2y

2 answers

Log in to vote
0
Answered by
Puppynniko 1059 Moderation Voter
2 years ago
Edited 2 years ago

input.UserInputType == Enum.KeyCode.T Will never work because UserInputType only works for checking mouse clicks and keyboards types Use input.KeyCode == Enum.KeyCode.T Or better yet use ContextActionService :)

Ad
Log in to vote
0
Answered by
C1RAXY 81
2 years ago
Edited 2 years ago

I noticed two errors. When you want to change the size of a 3D object it should be written as:

object.Size = Vector3.new(x,y,z) -- Value you want

Also I noticed that the if statement was wrong, you shouldn't check the enum, you should check the name or value of the keycode.

So the code should look like this:

local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local hum = plr.Character:WaitForChild("Humanoid")

UIS.InputBegan:Connect(function(input, gameProcessed)
    if input.UserInputType == Enum.UserInputType.Keyboard then
        print("Key:",input.KeyCode)
        wait(1)
        if input.KeyCode.Name == "T" then  -- https://create.roblox.com/docs/reference/engine/enums/KeyCode
            print("T was pressed at", input.Position)
            local Timestop = workspace:WaitForChild("Timestop")
            repeat  
            Timestop.Size = Vector3.new(Timestop.Size.X + 1 , Timestop.Size.Y + 1, Timestop.Size.Z + 1)
            task.wait(0.1)
            until Timestop.Size == Vector3.new(190, 190, 190)
            task.wait(60)
        end
    end
end)

https://create.roblox.com/docs/reference/engine/enums/KeyCode https://create.roblox.com/docs/reference/engine/classes/BasePart#Size https://create.roblox.com/docs/reference/engine/datatypes/Vector3

0
I don’t understand why are you not doing Input.KeyCode == Enum.KeyCode.T it’s how Roblox does it Puppynniko 1059 — 2y
0
It's the same thing as doing input.KeyCode.Name == "T" or input.KeyCode.Value == 116 C1RAXY 81 — 2y
0
its better to do Input.KeyCode == Enum.KeyCode.T so there wont be any problems if roblox changes the name of each Keycodes Puppynniko 1059 — 2y

Answer this question