Hello, making a simple check to see if the value inside of the players’ character is there, however it prints “did not find anything” in the output. Can someone help? Thanks. Here is my current code:
game.ReplicatedStorage.TPOnDeath.OnServerEvent:Connect(function(plr,stage)
task.wait(0.05)
print('recieved and waiutedg')
if plr.Character:FindFirstChild('StageTransferValue').Value == tonumber(stage) then
print('found?')
for _,v in pairs(workspace.Checkpoints:GetChildren()) do
print('looped')
if tostring(plr.Character:FindFirstChild('StageTransferValue').Value) == v.Name then
print('foudn amtch')
plr.Character:PivotTo(v.CFrame + Vector3.new(0,2,0))
print('tptpepdpl')
end
end
else
print('did not find anything')
end
end)
I am confused because you are asking if the StageTransferValue is equal to the value you sent via Remote Event, but if it’s changed on the Client, then it would never appear on the Server as changed.
edit: oops, forgot to include the value changed script for the value: here it is
function playerAdded(plr)
print(plr.Name)
plr.CharacterAdded:Connect(function()
local char = plr.Character
local val = Instance.new("IntValue")
val.Name = "StageTransferValue"
val.Parent = char
end)
end
function setNum(plr,valName)
local tag = plr.Character:FindFirstChild('StageTransferValue')
tag.Value = tonumber(valName)
end
game.Players.PlayerAdded:Connect(function(plr)
playerAdded(plr)
end)
for _,v in pairs(workspace.Checkpoints:GetChildren()) do
v.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
setNum(plr,v.Name)
end
end)
end
game.ReplicatedStorage.TPOnDeath.OnServerEvent:Connect(function(plr,stage)
task.wait(0.05)
print('recieved and waiutedg')
local StageTransferValue = plr.Character:FindFirstChild('StageTransferValue')
if StageTransferValue and StageTransferValue .Value == tonumber(stage) then
print('found?')
for _,v in pairs(workspace.Checkpoints:GetChildren()) do
print('looped')
if tostring(plr.Character:FindFirstChild('StageTransferValue').Value) == v.Name then
print('foudn amtch')
plr.Character:PivotTo(v.CFrame + Vector3.new(0,2,0))
print('tptpepdpl')
end
end
else
print('did not find anything')
print(StageTransferValue)
end
end)