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 6 years ago

sorry about the title

01the firer
02local player = game.Players.LocalPlayer --- this has to be in starter pack, this is a local script
03local mouse = player:GetMouse()
04local toggle = false
05 
06mouse.KeyDown:connect(function(key)
07 if not toggle and key == "x" then
08game.ReplicatedStorage.dark.tp:FireServer(mouse)
09end
10end)

this part wont work no errors

01game.ReplicatedStorage.dark.tp.OnServerEvent:Connect(function(player,mouse)
02        local epa = player.Character.Head:FindFirstChild("death")
03    if epa then
04        player.Character.HumanoidRootPart.CFrame = epa.CFrame
05        epa.Parent = workspace
06        epa:Remove()
07 
08 
09    end
10 
11 
12 
13end)
2
i refuse to help with code this poorly indented DinozCreates 1070 — 6y
0
sorry about that,trying to make something really fast the code is easy thou helleric -3 — 6y

2 answers

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

KeyDown Is Deprecated Use UserInputService

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

I'll Demonstrate

1local UIS = game:GetService("UserInputService")
2 
3UIS.InputBegan:connect(function(Input) --Whatever the player inputted EX: Mouse click or pressing E
4    if Input.KeyCode == Enum.KeyCode.E then--The Keycode can be anything; i'll just use e
5        --Code
6    end
7end)
0
;-; that dose not help much helleric -3 — 6y
0
now do you understand? Mr_Pure 129 — 6y
0
yep helleric -3 — 6y
Ad
Log in to vote
0
Answered by 6 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:

1local contextActionService = game:GetService("ContextActionService")
2 
3function [functionName]()
4 
5    game:GetService("ReplicatedStorage").dark.tp:FireServer()
6 
7 end
8 
9contextActionService:BindAction(xPressed,[functionName],false)

Not 100% this will work and sorry if it doesnt

Answer this question