Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago
Edited 3 years 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 3916 — 3y
0
i have just it wont work cjkizzy286 40 — 3y
0
you cant use starterpack, since it's in the player's character when it's equipped DarkDanny04 407 — 3y
0
so what do i use cjkizzy286 40 — 3y
View all comments (2 more)
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 407 — 3y
0
so how am i meant to do that. with a remote event? cjkizzy286 40 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years 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
Ad

Answer this question