sorry about the title
01 | the firer |
02 | local player = game.Players.LocalPlayer --- this has to be in starter pack, this is a local script |
03 | local mouse = player:GetMouse() |
04 | local toggle = false |
05 |
06 | mouse.KeyDown:connect( function (key) |
07 | if not toggle and key = = "x" then |
08 | game.ReplicatedStorage.dark.tp:FireServer(mouse) |
09 | end |
10 | end ) |
this part wont work no errors
01 | game.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 |
13 | end ) |
KeyDown Is Deprecated Use UserInputService
https://developer.roblox.com/api-reference/class/UserInputService
I'll Demonstrate
1 | local UIS = game:GetService( "UserInputService" ) |
2 |
3 | UIS.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 |
7 | end ) |
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:
1 | local contextActionService = game:GetService( "ContextActionService" ) |
2 |
3 | function [ functionName ] () |
4 |
5 | game:GetService( "ReplicatedStorage" ).dark.tp:FireServer() |
6 |
7 | end |
8 |
9 | contextActionService:BindAction(xPressed, [ functionName ] , false ) |
Not 100% this will work and sorry if it doesnt