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)
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)
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