Attribute Not Changing?

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
2 Likes

Is this a Local or Server script?

Are you supposed to be saving a Vector3 as a string? When you read it in the last touched function you don’t seem to be changing it back to a Vector3 value.

Have a look at the Attribute while you are playing to see if it’s actually being set.
When the player is teleported is the Attribute changing.

Try things like printing variables used for each if check before the check to see what the value is.

2 Likes

It is a Server Script,
Its saving a Vector3 I only used tostring to print out result for debugging
If I don’t include tostring I get an error trying to concatenate a string with a vector 3

I found the problem it was a slight typo error :expressionless: sorry about that lol thx though

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.