Server Script in Game > Workspace
local function PlayerAdded (Player)
local Stats = Instance.new("Folder")
local Stage = Instance.new("IntValue")
Stats.Name = "Stats"
Stage.Name = "Stage"
Stage.Value = 1
Stats.Parent = Player
Stage.Parent = Stats
end
local function CharacterAdded (Character)
wait(1)
local Player = game.Players:GetPlayerFromCharacter(Character)
local Stage = Player.Stats.Stage.Value --Gets stage value
print(Stage)
local Target = game.Workspace.Spawns:FindFirstChild(Stage).CFrame --Finds child with same name as value
Character.HumanoidRootPart.CFrame = Target + Vector3.new(0,12,0) --Moves character to the target and move up 12 studs
end
game.Players.PlayerAdded:Connect(PlayerAdded)
game.Workspace.ChildAdded:Connect(CharacterAdded)
Server Script found in parts in Game > Workspace > Spawns(Folder) > Parts(Any)
local function touched (Character)
local Player = game.Players:GetPlayerFromCharacter(Character.Parent) --Gets Player
local Stage = Player.Stats.Stage.Value --Gets the player's stage value
print(Stage)
if Stage == script.Parent.Name - 1 then --Checks if stage value is same as name of parent of script subtracted by 1
Stage = script.Parent.Name --Changes the player's stage value to the name of the parent of the script
print("Done!")
end
print(Stage)
end
script.Parent.Touched:Connect(touched)
Output
1
Done!
2
1 --this and bellow is me touching the part again and again
Done!
2
1
Done!
2
So my problem is that the value should change to 2 and when dying will go to the target with the same name as the value of stage which is supposedly 2, but as you can see in the output IT does change to 2 but when you touch the part again you can see its 1 again! I cant find any problem maybe some of you guys know. thanks
Also, i tried using print to see the stage value when dying and it shows 1, If it might help.
