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

Hold e to set spawn?

How would i make a script to where if you hold e and you respawn you will spawn at the place where you held e. This is my current script: (edit: I defined the spawn and put it an a script since i configured another script and it worked when i touched it and it wasn't a local script.)

local spawn = script.Parent
spawn.ProximityPrompt.Triggered:Connect(function(OnPromtTriggered)
	if OnPromtTriggered and OnPromtTriggered.Parent and OnPromtTriggered.Parent:FindFirstChild("Humanoid") then
		local player = game.Players:GetPlayerFromCharacter(OnPromtTriggered.Parent)
		local checkpointData = game.ServerStorage:FindFirstChild("CheckpointData")
		if not checkpointData then
			checkpointData = Instance.new("Model", game.ServerStorage)
			checkpointData.Name = "CheckpointData"
		end

		local checkpoint = checkpointData:FindFirstChild(tostring(player.userId))
		if not checkpoint then
			checkpoint = Instance.new("ObjectValue", checkpointData)
			checkpoint.Name = tostring(player.userId)

			player.CharacterAdded:connect(function(character)
				wait()
				character:WaitForChild("HumanoidRootPart").CFrame = game.ServerStorage.CheckpointData[tostring(player.userId)].Value.CFrame + Vector3.new(0, 4, 0)
			end)
		end

		checkpoint.Value = spawn
	end
end)

1 answer

so erm i see u posted this for aa while so ill just use an other script The local script in starterpack or smth:

local uis = game:GetService("UserInputService")
local timer = time()
uis.InputBegan:Connect(function(input, gpe)
    if (input.UserInputType == Enum.UserInputType.Keyboard) then
        if (input.KeyCode == Enum.KeyCode.E) then -- Or whatever key or input you want
            timeStarted = time()
        end
    end
end)
uis.InputEnded:Connect(function(input, gpe)
    if (input.UserInputType == Enum.UserInputType.Keyboard) then
        if (input.KeyCode == Enum.KeyCode.E) then -- Same key
            if time() - timer >= 3 then
-- i recomend you to add a checkpoint part in tool box,by searching "Obby spawn set" and name the part "CheckPoint",and put it in replicated storage,and u should make the part invisible and delete the decal on it,and make the part CanCollide false

local part = game.ReplicatedStorage.CheckPoint:Clone()
part.Parent = game.workspace
part.CFrame = game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame
wait(4)
part:Destroy()
end
        end
    end
end)

this is a quick script tho :/

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