Still have questions? Join our Discord server and get real time help.
0

# im trying to make a milk simulator and i cant gain milk why?

Edited 5 months ago

this is the code

game.StarterPack.Milk.Activated:Connect(function()
Milk.Value = Milk.Value + 1
end)

0
I suggest learning the basics before getting to complicated stuff. JesseSong 3371 — 5mo
0
i have just it wont work cjkizzy286 24 — 5mo
0
you cant use starterpack, since it's in the player's character when it's equipped DarkDanny04 392 — 5mo
0
so what do i use cjkizzy286 24 — 5mo
0
you can just put it into the tool, and then use script.Parent. you'll also need an event to actually change values serverside DarkDanny04 392 — 5mo
0
so how am i meant to do that. with a remote event? cjkizzy286 24 — 5mo

0
Edited 5 months ago

OK so this is the way I would do it, I would make a tool called "giveMilk" and put it in the starter pack, then i would make a folder called "Values" and put it inside StarterGui inside a screenGui, then put an int value called "milk" inside the folder, then I would create a local script that fires a remote event I created called milkTest(btw i tested it in studio so it should work for you). Finally make a script inside ServerScriptService that changes the value when the remote event is fired.And that is my answer to the problem. Go Ahead and try it out. Also this is the code feel free to use it:

--Local Script(Client)
script.Parent.Activated:Connect(function()

game.ReplicatedStorage.milkTest:FireServer()
end)

--Script(Server)
game.ReplicatedStorage.milkTest.OnServerEvent:Connect(function(player)
local milk=player.PlayerGui.ScreenGui.StatsValue.milk
milk.Value=milk.Value+1
end)


I almost forgot and had to edit this but, remember to turn the "RequiresHandle" property of the tool to false, and you might want to make a gui or leaderstats to show how much milk a player has and you can do so with a textlabel that has this code:

--Local Script(Client)
while wait(1) do
local playerstat=game.Players.LocalPlayer.PlayerGui.ScreenGui
script.Parent.Text=tostring(playerstat.StatsValue.milk.Value)
end