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

I'm trying to make a *Press a key to teleport*And it doesn't work.Can you help me?

Asked by 4 years ago

I'm making a Roleplay game and i was trying to make the doors like how the are in MeepCity.I press a specific key and it teleports me in the building. Thats what i've made.

Player = game.Players.LocalPlayer Mouse = Player:GetMouse()

Settings = {

CanTeleport = true;
WarpGui = true;t
TeleportKey = "e";t
TeleportTime = .1;


    }

   S = Settings

   UDIM = UDim2.new
   Mouse.KeyDown:connect(function(key)
local Enabled = true
if S.CanTeleport then
    if Enabled then
if key == S.TeleportKey then
Enabled = false
wait(S.TeleportTime)
if S.WarpGui then
local WarpGui = script.WarpGui:Clone()
WarpGui.Parent = Player.PlayerGui
for k = 0, 21, 1 do
WarpGui.MainFrame.Bar.Size = WarpGui.MainFrame.Bar.Size + UDIM(0, 10, 0, 0)
wait()
end
WarpGui:Destroy()
end

I tried to make it also with a GUI.But it doesn't work.

1 answer

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

this is only for the keyboard

Settings = {
    CanTeleport = true;
    WarpGui = true;
    TeleportKey = Enum.KeyCode.E;
    TeleportTime = .1;
    TeleporPart = workspace.PartTp --The player will move just in the position of this part.

}
local UserInput = game:GetService("UserInputService")
local S = Settings
local Enabled = true
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
UserInput.InputBegan:Connect(function(key)
    if key.KeyCode == S.TeleportKey then
        if S.CanTeleport then
            if Enabled then
                Character:MoveTo(S.TeleporPart.Position)
            end
        end
    end
end)
0
Thank you User#29004 0 — 4y
Ad

Answer this question