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

Changing Boolean Value Within Player?

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!

2 comments

0

Is their any error in the output?

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

1 answer

✓ Accepted answer
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

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