#bag can hold amount of food but when bag maximum increase the food stay the same as old bag
54 messages · Page 1 of 1 (latest)
?
is the food just a number
local foods = game.Workspace.Food
for i , food in foods:GetChildren() do
local debounce = false
local maxvalue = game.ReplicatedStorage.maxvalue.Value
food.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player and debounce == false then
local Food = player.leaderstats.Food
if Food.Value < maxvalue then
debounce = true
Food.Value += 1
food.Position = Vector3.new(math.random( -28 , 29), 10 , math.random( -28 , 28))
wait(0.5)
debounce = false
end
end
end
end)
end
this give me food
so it's resetting after you increase the maximum bag size
?
no i want to show u something
oh ok wait
i do intvalue named maxvalue on replicated storge
it is begain with 10
yep
10*
local changebag = script.Parent
local maxBag = game.ReplicatedStorage.maxvalue
changebag.MouseButton1Click:Connect(function()
maxBag.Value = 15
end)
and here button if i pressed on it
oh
so the first script is a server script and the second one a local?
u gotta send a remote event to the server
and change it from there
changing it on the client like that doesn't change it on the server
you're changing the max value on the client
but for security reasons and because nothing gets automatically replicated from client to server, only the other way around, the server doesn't see that change
i need to open live to see i do remote control wrong or no
or if you don't want to get into that, another solution is just changing your 2nd script to a server script @bold acorn
server ?/
it probably has some weird side effects but I don't think you're worried about that
why
because then you won't need a remote event
if i change from local to normal script that will mean server all will affect