uuh im pretty sure i may be really stupid and its like a 1 minute fix but i am quite inexperienced with coding and need a second set of eyes to help me out
so i have these windmill things that you can buy for your tycoon, when you buy them theyre just supposed to give you 1 cash every 0.2 seconds
they spin and they play sounds just fine, and when you load them in using saved data they do generate cash, but when you first buy them they give nothing ??
ive been rearranging and rewriting this code for way too much time and i just want to get it over with and i dont know why it refuses to work PLEASE HELP ME
i will answer questions and send whatever is asked of me
#petulant windmill refuses to give me cash
1 messages · Page 1 of 1 (latest)
the second while loop was my shoddy attempt at troubleshooting, i need to rewrite this
hold
my studio crashed hold for longer please
are there any slurs that can be used against roblox studio
idk 😭
hello
are you assigning the player value correctly?
as you buy the windmill, it IS assigned, right?
ah
i think that may be the issue here
also, if the player value continues to be nil, the while loop will run forever and on potentially crashing things (i think they fixed this but its good to do this anyway)
just print the player already 😭
i used code from the tycoon core script
please add a wait inside your while loop to avoid crashing
i think i may have fucked up the loop slightly and now it shoots studio
nvm
cause ur loop is running with no delay it crashes
add a wait
inside your first while loop
that means you arent assigning the player value correctly, probably
okay joining game it starts off nil
expected
though it shouldnt be running so early
double check where you're assigning the player value, and add a wait inside the first while loop
i added the wait
you could do
if player ~= nil then
--code
else
task.wait(1)
end
upon claiming the tycoon it retrieved save data and the player data was correctly assigned to me
let me reset the tycoon
so it wont crash anymore
okeh
if i buy it
local player = values.OwnerValue.Value
if not player then
player = values.OwnerValue:GetPropertyChangedSignal("Value"):Wait()
end
do something like this if it runs to early
please send the code that runs when you buy the windmill and set the players value
he just said the player is correct 🙏
stupid infernal windmill
correct
local values = script.Parent.Parent.Parent.Values
local center = script.Parent.Build:FindFirstChild("Center")
local ambience = script.Parent:WaitForChild("WindmillAmbience")
ambience.Parent = center
ambience:Play()
while true do
task.wait()
local player = values.OwnerValue.Value
print(player)
if player ~= nil then
while true do
local WINDMILL_TIME = 0.15 + math.random() * 0.1
player.leaderstats.Electrons.Value += 1
task.wait(WINDMILL_TIME)
end
end
end
current
my droppers and furnace and everything work fine so i am very confused
when you print player, it's just fine?
it prints this
now when i loaded the tycoon it didnt even print player yet it still gives me cash ????
hm
upon resetting it does print the player
where is this script, by the way?
yet it only prints once
** You are now Level 4! **
oh it's in the windmill
correct
gosh
I JUST WANT IT TO CONSTANTLY ADD CASH TO THE TYCOON WITHOUT ANY PARTS BEING DROPPED
WHY DOES IT DO THIS
do i have to rewrite the entire thing
interestingly the windmill even manages to add cashonce or twice after resetting, so you just start off with 2 cash instead of 0
when the player claims the tycoon door
or when the player resets the tycoon, where it sets the value for the cloned tycoon that replaces the original
when does it start working?
when the windmills are bought, get saved to serverstorage and when the player reconnects and claims the tycoon again
and you set the player value all the same?
the electrons value exists by then, right?
it gets created when the player joins?
electrons = cash in this case
electrons value gets created when the player joins as leaderstats is in serverscriptservice
local values = script.Parent.Parent.Parent.Values
local center = script.Parent.Build:FindFirstChild("Center")
local ambience = script.Parent:WaitForChild("WindmillAmbience")
ambience.Parent = center
ambience:Play()
while true do
task.wait()
local player = values.OwnerValue.Value
print(player)
if player ~= nil then
print('Ran!')
while true do
local success, error = pcall(function()
local WINDMILL_TIME = 0.15 + math.random() * 0.1
player.leaderstats.Electrons.Value += 1
end)
print(error)
task.wait(WINDMILL_TIME)
end
end
end
try ts
tell me what shows up in output
sorry for the ass formatting im on mobile 🙏
could we please wrap the while true do function inside a
task.spawn(function()
)
😭
starting console
nil is the player value that hasnt been set
really not sure why the second error takes place but it doesnt cause issues so ill deal with it later
oh shit i have made an error 🙏
its not that but uh
electrons are going up a mile a minute and somethings getting printed as nil
yeahyeah
** You are now Level 9! **
my bad 🙏
upon resetting, it does say "Ran!"
WHY THE FUCK ARE WE NOT USING THE REGULAR CONSOLE LIKE EVERYTHING IS SO ASS HERE
local values = script.Parent.Parent.Parent.Values
local center = script.Parent.Build:FindFirstChild("Center")
local ambience = script.Parent:WaitForChild("WindmillAmbience")
ambience.Parent = center
ambience:Play()
local WINDMILL_TIME = .15
while true do
task.wait()
local player = values.OwnerValue.Value
print(player)
if player ~= nil then
print('Ran!')
while true do
local success, error = pcall(function()
local WINDMILL_TIME = 0.15 + math.random() * 0.1
player.leaderstats.Electrons.Value += 1
end)
print(success)
task.wait(WINDMILL_TIME)
end
end
end
LMFAO EVEN MY FORMATTING
dawg
why is windmill time defined twice
oh FUCK
change the local WINDMILL_TIME inside the while loop to just
WINDMILL_TIME
🙏
yall gotta calm the fuck down this aint going anywhere fr
which while true
the windmillambience
is just not there apparently
yet i heard it
💀
maybe it was parented late
I have no idea
does it fucking work 😭
instead of redefining the windmilltime I wanted to just update it
it seems to be successful??
you changed it to update windmill time right
i currently just left windmill time to .15
okay it doesnt play any audio after resetting
now i will proceed to buy
show output
local values = script.Parent.Parent.Parent:FindFirstChild("Values")
local ownerValue = values:FindFirstChild("OwnerValue")
local center = script.Parent.Build:FindFirstChild("Center")
local ambience = script.Parent:FindFirstChild("WindmillAmbience")
if center and ambience then
ambience.Parent = center
ambience:Play()
else
print("abience or center not found")
end
local running = nil
local function startGenerating(player)
if not player then print("player not found") return end
running = task.spawn(function()
print("started while loop")
while ownerValue.Value == player do
local leaderstats = player:FindFirstChild("leaderstats")
local electrons = leaderstats and leaderstats:FindFirstChild("Electrons")
if not electrons then print("electrons not found") break end
electrons.Value += 1
task.wait(0.15 + math.random() * 0.1)
end
end)
end
if ownerValue.Value then
print("player is currently assigned")
startGenerating(ownerValue.Value)
end
ownerValue:GetPropertyChangedSignal("Value"):Connect(function()
running = nil
if ownerValue.Value then
print("player is currently assigned")
startGenerating(ownerValue.Value)
end
end)
🙏
gogo
task.spawn(function()
)
is just there that you can do stuff in the script below and the while true loop runs next to the script
what does the console say
peak
does everything work?
okay so
** You are now Level 5! **
i reset my tycoon
the red stuff appeared when it set my player value
second one is when i bought it
except
i could hear the ambience and im pretty sure it was parented to center????
very strange
now i looked back and it was increasing
i am so confused
THE CODE WORKS
THANK YOU
np
now how do i clean it up so theres none of these strange prints
lemme explain the task.spawn thing again incase you wanna edit the script
this is a while true loop with task.spawn
task.spawn(function()
while true do
task.wait()
end
)
print("i will instantly run")
this is a while true loop with no task.spawn
while true do
task.wait()
end
print("i will never run")
curious
idk its more of an advanced thing but its pretty useful
i will research this more
thank you
this was horrific to deal with but i am at peace now
jeez, what a mess
rat poison
well u get what u pay for with these free tycoon scripts 🤷
i am breaking those scripts to fit my image
i came in with zero coding knowledge
i am constructing some seriously freaky yet functional shit now
scripting your own tycoon framework aint even that hard i think you could learn it in a week or two
likely
you are stitching code, copy+pasting existing code and trying to bodge your way into something that kind-of works. most people can do that... until something breaks that you cannot fix or want to do something that doesn't already exist, as you have experienced here, and then the whole thing starts to unravel ;p
flourish my constructs
you'd do yourself many favors by learning the language from the ground up 👍 https://create.roblox.com/docs/tutorials/fundamentals/coding-1/coding-fundamentals
i started off with that, now ive memorized enough to actively construct something that seems pretty good (until its A FUCKING WINDMILL (FUCK))
pyro fire you are a poet
i do get issues frequently but usually its not as severe as this and i can fix them with little issue
if i were a poet, i for one wouldn't know it.
it seems fine for now but i might need to do a code efficiency consult later just to make sure everythings going dashing
you are nearly as cool as herman but herman is a lil cooler then you
political
well no better opportunity to work on your debugging skills which is just prints, breakpoints, and visual indicators (spawning parts to show stuff). never assume any of your code works until you can prove it is working usually with prints.
and if there's some particular thing not working, trace it from start to end, prove each step.
just for future 
i think ill have to do a bit of debugging for these creatures
just dont fall into the humanoid.movetofinished:wait() newb trap https://create.roblox.com/docs/characters/pathfinding
fuck pathfinding 😭
skill issue 😎

for now the zombies are partly stolen code but with damage and flinch and attack animations and sounds and other shit added on
i need to research how to turn it into more of 'my' code
https://create.roblox.com/docs/tutorials/fundamentals/coding-1/coding-fundamentals
WHERE DO YOU FIND THIS PYRO LIKE THERE IS LEGIT NOT A SINGLE WAY TO GET THERE WITHOUT HAVING THE LINK
if theres any issue im having with them, its that (if i understand correctly) the idle animation attempts to play mid-walk animation, resetting it
i temporarily removed the thing in the code that sets the idle and it did let the whole walk animation play out, just looked jank because of the idle not playing when its actually required
well for starters you can just search for those pages
but like it would be so much more useful if this is somewhere to find in the docs
second yeah it's a bit of a maze but the info is there if you look for it and just keep reading stuff https://create.roblox.com/docs/scripting
the docs are organzised so ass
so the animation stuff is usually just a state machine with code to switch between states. if things are playing out of order then the logic is going wrong somewhere, so what you'd do is trace/debug/prove all the code that is near the walk animation play code, as well as stuff that deals with walk states like humanoid.running or movedirection changed etc.
noted
like for every walkanimtrack:Play(), put a print next to it so you know the code is running
and if its running when it shouldn't be well you've just found your problem 👍
prints really are that powerful.
point is it may look like high level scripters magically know how to write code perfectly the first time but that's not true, it's just a lot of practice. trial and error, and a lot of it, is normal 👍
