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

How come my script says attempt to index boolean with 'Name'?

Asked by 4 years ago
Edited 4 years ago

The error is 17:16:08.368 - Players.techingenius.PlayerGui.Shop.Bought:4: attempt to index boolean with 'Name' and I'm using a script, any help? It used to work

game.Workspace.Owned.ACR.Changed:Connect(function(player)
    if game.Workspace.Owned.ACR.Value == true then
        local Clone = game.ServerStorage.ACR:Clone()
        Clone.Parent = game.Workspace[player.Name]
    end
end)
0
The changed parameter returns the property thats being changed, not the player.      game.Workspace.Owned.ACR.Changed:Connect(function(propertyBeingChanged) killerbrenden 1537 — 4y
0
Then how would I fix it? techingenius -82 — 4y
0
Is this a LocalScript? killerbrenden 1537 — 4y
0
no techingenius -82 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

The Changed event has a parameter of the property that's being changed.

So in this case, whenever the Value property changes, it's being referenced as "player".

I'm not so sure on how to fix this using a BoolValue.

You could use a StringValue and make it whenever no one own's it, it says "Unowned" if someone does own it, then it should say the player's name that owns it.

game.Workspace.Owned.ACR.Changed:Connect(function(property)
    if property == "Value" then
        if game.Workspace.Owned.ACR.Value ~= "Unowned" then
            local clone = game.ServerStorage.ACR:Clone()
            clone.Parent = game.Workspace[game.Workspace.Owned.ACR.Value]
        end
    end
end)

Something along the lines of this should work. But, you'll have to do checks to see if anyone doesn't own it, and if no one own's it, then change the value of it to "Unowned".

But, hope this somewhat helped! Feel free to select this as an answer if this helped!

Ad

Answer this question