Hello,
I’m trying to create a checkpoint system where when a checkpoint is touched it will set a attribute to the touched checkpoints vector3 which is used when the player touches a reset part. But it doesn’t work when I touched the reset part it DOES teleport me buts it taking me to the start line position which is the default value. If anyone could help I would appreciate it.
local cs = game:GetService("CollectionService")
local remoteEvent = game.ReplicatedStorage.FakeRespawnPlayer
game.Players.PlayerAdded:Connect(function(plr)
plr:SetAttribute("CurrentCheckpoint", workspace.Map["Starting Line"].Position)
end)
for _, part in cs:GetTagged("checkpoint") do
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
part.Color = Color3.new(0, 1, 0.333333)
-- Saves a vector3 value
game.Players:GetPlayerFromCharacter(hit.Parent):SetAttribute("CurrenctCheckpoint", part.Position)
print("Set Attribute to "..tostring(game.Players:GetPlayerFromCharacter(hit.Parent):GetAttribute("CurrentCheckpoint")) )
end
end)
end
for _, part in cs:GetTagged("resetBrick") do
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.HumanoidRootPart.Position = game.Players:GetPlayerFromCharacter(hit.Parent):GetAttribute("CurrentCheckpoint")
end
end)
end