Ninjaluxray7685 Posted 5 hours ago Share Posted 5 hours ago (edited) so i have been letting chatgpt teach me how to script because i couldn't find a video to teach me how to create a 1-20 chance roll system for a object to simulate rolling a d20 but for what ever reason its failing the save with a error here is my script and screenshot of my work can some one please help me im getting annoyed trying to make this work error i get is "ApplySpell is not a function or does not exist" or when i change applyspell > cast i get "Cast is not a function or does not exist" Spoiler Scriptname SaintCastTreasureScript extends ObjectReference MiscObject Property SaintCastTreasure Auto ; Reference to the Saint Cast Treasure item Weapon Property BladeOfDestiny Auto ; Reference to the Blade of Destiny Spell Property StunEffect Auto ; Reference to the Stun spell/effect Spell Property FearEffect Auto ; Reference to the Fear spell/effect Spell Property CritFailEffect Auto ; Reference to the Crit Fail effect (e.g., summon a Dremora) Spell Property BoostEffect Auto ; Reference to the temporary stat boost effect Spell Property InstantKillEffect Auto ; Reference to the Instant Kill effect Message Property MsgCritFail Auto ; Reference to the Crit Fail message box Message Property MsgStun Auto ; Reference to the Stun message box Message Property MsgFear Auto ; Reference to the Fear message box Message Property MsgBoost Auto ; Reference to the Boost message box Message Property MsgInstantKill Auto ; Reference to the Instant Kill message box Message Property MsgDrainMagickaStamina Auto ; Reference to the Drain Magicka and Stamina message box Form Property Gold001 Auto ; Reference to the gold item Form Property DragonBone Auto ; Reference to the Dragon Bone item Form Property DaedraHeart Auto ; Reference to the Daedra Heart item Form Property DragonScales Auto ; Reference to the Dragon Scales item Event OnEquipped(Actor akActor) ; Only run the script if the player interacts with the Saint Cast Treasure if akActor == Game.GetPlayer() int rollResult = Utility.RandomInt(1, 20) ; Handle the different roll outcomes if rollResult == 1 MsgCritFail.Show() akActor.Cast(CritFailEffect, akActor) ; Apply Crit Fail Effect (e.g., summon a Dremora) elseif rollResult >= 2 && rollResult <= 6 MsgDrainMagickaStamina.Show() akActor.DamageActorValue("Magicka", 50) akActor.DamageActorValue("Stamina", 50) elseif rollResult >= 7 && rollResult <= 11 MsgStun.Show() akActor.Cast(StunEffect, akActor) ; Apply Stun Effect directly to the actor elseif rollResult >= 12 && rollResult <= 17 MsgFear.Show() akActor.Cast(FearEffect, akActor) ; Apply Fear Effect directly to the actor elseif rollResult >= 18 && rollResult <= 19 MsgBoost.Show() akActor.Cast(BoostEffect, akActor) ; Apply Boost Effect directly to the actor elseif rollResult == 20 MsgInstantKill.Show() akActor.Cast(InstantKillEffect, akActor) ; Apply Instant Kill Effect directly to the actor ; Add rewards to the player Game.GetPlayer().AddItem(Gold001, 250) Game.GetPlayer().AddItem(DragonBone, 1) Game.GetPlayer().AddItem(DaedraHeart, 1) Game.GetPlayer().AddItem(DragonScales, 3) endif endif EndEvent Edited 5 hours ago by redlink32 Link to comment Share on other sites More sharing options...
IsharaMeradin Posted 1 hour ago Share Posted 1 hour ago The correct syntax for Cast is: mySpell.Cast(mySource,myTarget) The reason it is creating an error is that Cast is a function on the Spell script rather than the Actor script. Thus having the actor call Cast results in the error you are seeing. Link to comment Share on other sites More sharing options...
Recommended Posts