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

idk what i am doing wrong it wont tp me when i use remote event how do i fix?

Asked by 5 years ago

sorry about the title

the firer 
local player = game.Players.LocalPlayer --- this has to be in starter pack, this is a local script
local mouse = player:GetMouse()
local toggle = false

mouse.KeyDown:connect(function(key)
 if not toggle and key == "x" then
game.ReplicatedStorage.dark.tp:FireServer(mouse)
end
end)

this part wont work no errors

game.ReplicatedStorage.dark.tp.OnServerEvent:Connect(function(player,mouse)
        local epa = player.Character.Head:FindFirstChild("death")
    if epa then
        player.Character.HumanoidRootPart.CFrame = epa.CFrame 
        epa.Parent = workspace
        epa:Remove()


    end



end)
2
i refuse to help with code this poorly indented DinozCreates 1070 — 5y
0
sorry about that,trying to make something really fast the code is easy thou helleric -3 — 5y

2 answers

Log in to vote
1
Answered by
Mr_Pure 129
5 years ago
Edited 5 years ago

KeyDown Is Deprecated Use UserInputService

https://developer.roblox.com/api-reference/class/UserInputService

I'll Demonstrate

local UIS = game:GetService("UserInputService")

UIS.InputBegan:connect(function(Input) --Whatever the player inputted EX: Mouse click or pressing E
    if Input.KeyCode == Enum.KeyCode.E then--The Keycode can be anything; i'll just use e
        --Code
    end
end)
0
;-; that dose not help much helleric -3 — 5y
0
now do you understand? Mr_Pure 129 — 5y
0
yep helleric -3 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

I dont think it will work because you are firing the function when some one clicks and then checking if they have clicked the key x. Maybe try using ContexActionService instead.

For example:

local contextActionService = game:GetService("ContextActionService")

function [functionName]()

    game:GetService("ReplicatedStorage").dark.tp:FireServer()

 end

contextActionService:BindAction(xPressed,[functionName],false)

Not 100% this will work and sorry if it doesnt

Answer this question