Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Studio not noticing a value's Value?

Asked by 8 years ago
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.

0
If you were attemping to bold your text it should look like this: " **Text**. This is just for your formatting, koolkid8099 705 — 8y
0
== ("Player") is comparing the Owner.Value with a string value, I think you mean to compare it against the player Instance. DevSean 270 — 8y
0
Its if the string value is "Player" Volodymyr2004 293 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago
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)
Ad

Answer this question