Keep getting this same (infinite yield) in output, Maybe my Module in ServerScript is not being activated no Idea, Followed You-tuber Alvin Egg opening
What solutions have you tried so far?
I tried adding a timeout to the end of my script which solves the infinite yield but I could never get the button to work… any help would be nice
searched on dev forums, YouTube comments, also on google(+3 pages) Determined to figure out where the issue is.
These are the scripts in my current build
ServerServiceScript Pet Module
local petModule = {}
petModule.pets = {
["Legendary"] = {
game.ReplicatedStorage:WaitForChild("Pets"):WaitForChild("IceBunny");
};
["Epic"] = {
game.ReplicatedStorage:WaitForChild("Pets"):WaitForChild("Reindeer");
};
["Rare"] = {
game.ReplicatedStorage:WaitForChild("Pets"):WaitForChild("Bee");
};
["Common"] = {
game.ReplicatedStorage:WaitForChild("Pets"):WaitForChild("Reindeer");
game.ReplicatedStorage:WaitForChild("Pets"):WaitForChild("Bear");
};
}
petModule.rarities = {
["Legendary"] = 5;
["Epic"] = 15;
["Rare"] = 30;
["Common"] = 50;
}
petModule.chooseRandomPet = function()
local randomNumber = math.random(1,100)
local counter = 0
for rarity, weight in pairs(petModule.rarities) do
counter = counter + weight
if randomNumber <= counter then
local rarityTable = petModule.pets[rarity]
local chosenPet = rarityTable[math.random(1,#rarityTable)]
return chosenPet
end
end
end
return petModule
you should do those checks on the server also [THE MINUS] and server modules cant be accessed by clients so put it in replicated storage so it can be shared modules
I see that you are using MouseClick on a GUI object, when you need to use MouseButton1Click. Also, you should be subtracting values on the server, not on a local script.
thanks for the mouse button click! also if I remove the values from the button wouldn’t I need to attach the button in another script to know what’s being clicked? also wouldn’t I be able to get this method working as is or is it exploitable that’s why I should change it
You would just need to do script.Parent.TextButton.MouseButton1Click:Connect(function() instead. Well, it can be exploitable, but the values won’t actually subtract if you are doing it from the client. All you would need to do is that when the button is clicked, it fires an event. Then you can do checks to see if the player has enough money on the server, and everything else. There’s really no need to change the location of your module script by doing it through a remote event.
Anything labeled as server in general cannot be accessed through the client. For the sake of simplicity as I can see you’re just starting out try ReplicatedStorage instead. If it were up to me I’d get the contents from the Server with a Remote Function at the client’s load and return the contents of the module you desire. So you can try that if you want to keep that data on the server side.