Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Studio not noticing a value's Value?

local Character=script.Parent.Parent.Parent.Parent.Character
local Build=script.Parent.Parent.Parent.Parent.Parent.Parent.Workspace.Build
wait(1)
Character.OwnsBuild.Changed:connect(function()
    local table = game.Workspace:GetChildren()
    for i,v in pairs (table) do
        if v.Name == "Build" then
            print("Model Detected")
            if v.Owner.Value ==("Player") then
				print(v.Owner.Value)
				local Cashtie=v.Cash
				print(Cashtie)
				script.Parent.Text="Cash: $"..Cashtie.Value
				Cashtie.Changed:connect(function(NewValue)
					if Cashtie.Parent.Owner.Value==script.Parent.Parent.Parent.Parent then
						script.Parent.Text="Cash: $" ..NewValue
					end
				end)
           else
			print(v.Owner.Value)
		 	end
        end
    end
end)



My problem is that nothing is running after the line if v.Owner.Value ==("Player") then however after else it prints Player. Someone help? This script is located inside of the text button inside of Playergui btw.

3 comments

0

If you were attemping to bold your text it should look like this: " Text. This is just for your formatting,

0

== ("Player") is comparing the Owner.Value with a string value, I think you mean to compare it against the player Instance.

0

Its if the string value is "Player"

1 answer

✓ Accepted answer
local Character=script.Parent.Parent.Parent.Parent.Character
local Build=script.Parent.Parent.Parent.Parent.Parent.Parent.Workspace.Build
wait(1)
Character.OwnsBuild.Changed:connect(function()
    local table = game.Workspace:GetChildren()
    for i,v in pairs (table) do
        if v.Name == "Build" then
            print("Model Detected")
            if v.Owner.Value.Name ==("Player") then
		--[[
		since Owner is an ObjectValue, comparing it with a string always returned false
		instead you needed v.Owner.Value.Name == "Player"
		--]]
                print(v.Owner.Value)
                local Cashtie=v.Cash
                print(Cashtie)
                script.Parent.Text="Cash: $"..Cashtie.Value
                Cashtie.Changed:connect(function(NewValue)
                    if Cashtie.Parent.Owner.Value==script.Parent.Parent.Parent.Parent then
                        script.Parent.Text="Cash: $" ..NewValue
                    end
                end)
            else
            	print(v.Owner.Value)
            end
        end
    end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.