✓ Accepted answer
If you still need help then I have created a script for this.
First, you would need to create a RemoteEvent and place that inside of ReplicatedStorage.
Then, create a LocalScript and place that inside of StarterGui with the following code inside:
LocalScript
local event = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(key, gpe)
if key.KeyCode == Enum.KeyCode.F and not gpe then
event:FireServer()
end
end)
The code will check if the player pressed the F key and it would fire the RemoteEvent
Lastly, create a Script and place that inside of ServerScriptService with the following code inside:
Server Script
local event = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
event.OnServerEvent:Connect(function(player)
player:LoadCharacter()
end)
The code will fire after the player has pressed the F. key. LoadCharacter() will reload the player's character making it respawn.
5 comments
first of all use UserInputService Enum.KeyCode then you need a remote event then u reload your char from there
Server Script
Okay thanks that helped
What kind of advice is that?
use userinputservice