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

Changing Boolean Value Within Player?

Asked by 8 years ago
function oc(pl, dc)
    if (dc.Name == "Yes") then
        print("You own this tycoon!")
        workspace.Tycoon.DoorHeader.UnownedPharmacy.Name =pl.Name.."'s Tycoon"
        if not pl.Name.hastycoon.Value then
            pl.Name.hastycoon.Value=true
            script.Parent.Parent.Parent.Parent.Parent.OwnerName.Value=pl.Name
        end
    end
    if (dc.Name =="No") then
        print("You do not own this tycoon!")
    end
end
script.Parent.DialogChoiceSelected:connect(oc)

The function of this script is to allow a player to initiate dialog, and claim a tycoon, without being able to claim another. When I start the game and go through the dialog, the hastycoon value is not changed to true and I'm a little stuck as to why.

Thanks!

0
Is their any error in the output? NinjoOnline 1146 — 8y
0
I tried your solution and it didn't work, but there was an error in the output this time. "Workspace.Tycoon.Model.Manager.Head.Dialog.Dialog Claim:9: attempt to index field 'hastycoon' (a nil value)" I have properly identified "hastycoon" , set it to false, and set its parent as the player with hastycoon.Parent=plr carcanken 65 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago
function oc(pl, dc)
    if (dc.Name == "Yes") then
        print("You own this tycoon!")
        workspace.Tycoon.DoorHeader.UnownedPharmacy.Name =pl.Name.."'s Tycoon"
        if not pl.Name.hastycoon.Value then
            pl.hastycoon.Value=true -- Error was here
            script.Parent.Parent.Parent.Parent.Parent.OwnerName.Value=pl.Name
        end
    end
    if (dc.Name =="No") then
        print("You do not own this tycoon!")
    end
end
script.Parent.DialogChoiceSelected:connect(oc)

I believe this should work. It was because you were trying to look inside the players name for the hastycoon value, instead of the player itself.

Make sure +1 and accept answer to help others.

  • NinjoOnline
Ad

Answer this question