What it is supposed to do is respawn/load your character when you press "f." I haven't scripted in a month and I kind of forgot some stuff :') So here it is.
script.Parent = game.StarterGui wait() local k = game.Players.LocalPlayer:GetMouse() k.KeyDown:connect(function(a) if a:lower() == "f" then local c = game.Players.LocalPlayer.Character if c then local h = c:findFirstChild("Humanoid") if h then h:LoadCharacter() end end end end)
I'm not sure what to do so can someone help me?
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 --if player pressed the key F it would trigger this event:FireServer() -- fire the server so it could reload the player 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) -- when event is fired player:LoadCharacter() -- respawn the player end)
The code will fire after the player has pressed the F. key. LoadCharacter() will reload the player's character making it respawn.