wait(0.5)
local char = script.Parent
local oldval = game.ReplicatedStorage:FindFirstChild("TpVal"..char.Name)



if oldval ~= nil then
	print("not nil")
	script.Parent.RestorePlrHomePos.Disabled = false
	wait(0.1)
	script.Parent.TpPosServerSync.Disabled = false
	wait()
	script.Disabled = true
end


if oldval == nil then
	print("nil")
	local tpval = Instance.new("Vector3Value")
tpval.Name = "HomeTp:"..char.Name
tpval.Parent = game.ReplicatedStorage
script.Parent.TpPosServerSync.Disabled = false
wait()
script.Disabled = true
end

here is my problem: this script first checks in replicatedstorage for a value with "TpVal (characters name)" if its not there it runs the bottom portion of the script, if it is there then it runs the upper portion. the problem is even if the value IS there it always returns nil rather than not nil.

4 comments

0

instead of two if statements try that first if statements followed by an elseif

0

statement*

0

it still returned nil regardless of there being a value in replicatedstorage.

0

Try extending the wait, it could be that it just doesnt exist yet. You sadly cant use waitforchild since thats the entire point of the code.