So you need to add a script onto your MagicEffect for your potion. When you go to add a new script, you'll see a new window appear. The first line you have to enter is your scriptname. Name it whatever you want, but it's good practice to prefix your script with something (a unique few letters representing your name, mod name, etc) for compatibility with other mods.
Then you'll see by default that the script extends "ActiveMagicEffect." Leave this as it is. If you go to the Creation Kit wiki page for ActiveMagicEffect, you'll see all the functions you can call on this type of object, but most importantly for you is the Events. Events are special functions which are triggered by something, and they can also give you a few variables to use relating to whatever happened. For you, it would be easiest to use OnEffectStart, which is triggered as soon as the Magic Effect is applied. http://www.creationk...veMagicEffect.?/a> Here they give you variables pointing to both the target and the caster (akTarget/akCaster) of the effect so you can manipulate them however you want.
The next thing that is important for scripting is properties. These point to an object in the game (Spell, Message, etc) or hold a value (float, int, bool, string). You fill these out by right-clicking your script and selecting edit properties.
So to actually make your script, fill out the name for your script in the new script window and hit OK. Right click your script and select edit script. Something like this below should work for you. I added comments to explain what is going on in the script.
Scriptname _test_testscript extends ActiveMagicEffect ;your sciprt name goes in place of _test_testscriptSPELL Property MyDisease Auto ;fill these property out in the MagicEffect windowMessage Property MyMessage AutoFloat Property fChance Auto ;fill this property with the disease chance (ex: 15% = 15.0);This event is triggered when the magic effect is applied, the akTarget variable points to the target of the magic effect.;Likewise akCaster is the caster of the magic effect. akCaster and akTarget can be the same actor for self targeted effectsEvent OnEffectStart(Actor akTarget, Actor akCaster) if Utility.RandomFloat(0.0, 100.0) <= fChance ;compare the randomly generated number to the disease chance akTarget.AddSpell(MyDisease, false) ;Condition is met. Adding the disease to the target. The false parameter suppresses the default message "Disease added." MyMessage.Show() ;"You have contracted MyDisease" make sure your message is not a messagebox endIfendEvent
Also, if you want the player's disease risk to factor in, you have to take a few additional steps as the AddSpell function doesn't check that.
Scriptname _test_testscript extends ActiveMagicEffectSPELL Property MyDisease AutoMessage Property MyMessage AutoFloat Property fChance Auto Event OnEffectStart(Actor akTarget, Actor akCaster) float fResist = akTarget.GetAV("DiseaseResist") if fResist >= 100.0 return ;immediately ends the function because the target is immune to disease endIf if Utility.RandomFloat(0.0, 100.0) <= fChance*(100.0-fResist)*0.01 ;compare the randomly generated number to the disease chance akTarget.AddSpell(MyDisease, false) MyMessage.Show() endIfendEvent