Recommended Posts

EscapeMan4    1

So I've been trying to make a character that will spawn in a certain amount of ice everyday at the same time, and preserve perishable items while it's in their inventory. How would I go about doing this?

Share this post


Link to post
Share on other sites
Serpens    518

look at already existing code and how it is done there. eg. the white chester or the insulated backpack.
And to spawn ice you can use the inst:WatchWorldState("isday", SpawnIceFunction). This function then is called at beginning of every day.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
Serpens    518
8 hours ago, EscapeMan4 said:

Thank you, but now I'm encountering this problemimage.png.9c18dfcf3c396a1856bfcf47585768d2.png

I guess you copied "inst:WatchWorldState("isday", SpawnIceFunction)" without adding any code of your own?
Of course you have to define and write the SpawnIceFunction. The error message says, tha tis trying to call a function that is nil (not defined)

Share this post


Link to post
Share on other sites
EscapeMan4    1
12 hours ago, Serpens said:

I guess you copied "inst:WatchWorldState("isday", SpawnIceFunction)" without adding any code of your own?
Of course you have to define and write the SpawnIceFunction. The error message says, tha tis trying to call a function that is nil (not defined)

No this is the code set for spawning ice

 

local icee = SpawnPrefab("ice").Transform:SetPosition(inst.Transform:GetWorldPosition())
	inst:WatchWorldState("isday", icee)

 

Share this post


Link to post
Share on other sites
Hornete    1,171
26 minutes ago, EscapeMan4 said:

No this is the code set for spawning ice

 

 

That's not a function, you need to do something like this
 

local function icee(inst)
		SpawnPrefab("ice").Transform:SetPosition(inst.Transform:GetWorldPosition())
 end

	inst:WatchWorldState("isday", icee)
  • Like 1
  • Thanks 2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now