Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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 comments

2

i refuse to help with code this poorly indented

0

sorry about that,trying to make something really fast the code is easy thou

2 answers

✓ Accepted answer

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)

3 comments

0

;-; that dose not help much

0

now do you understand?

0

yep

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

This discussion is preserved as it was. New answers, comments, and votes are closed.