-
What do you want to achieve? Basically have I have a Food contest game where you press buttons at the screen and the food shrinks down until its finished and move on to another random type of food.
-
What is the issue? So I have a function in a module that get fired by the server side, and a local script that controls the button at the screen and when you reach a certain click you start with the next meal, I’ve made it so that the module fires the local script so that the ui get visible and starts counting, and refires the module to get the next food, the issue that the module succeed to fire the local script only one time, and then it doesn’t do it anymore.
-
What solutions have you tried so far? I’ve tried to search up the issue but no one has any similar problem to mine.
Module
function MapsHandler.Main(plr, map)
local nextFood = game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("NextFood")
local FoodExist = game.ReplicatedStorage:WaitForChild("Values"):WaitForChild("FoodExist")
local bitting = game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("Bitting")
local Foods = game:GetService("ReplicatedStorage"):WaitForChild("foods"):GetChildren()
local function NewFood()
local InRound = script.Parent.Parent:WaitForChild("Values"):WaitForChild("Inround")
local FoodExist = game.ReplicatedStorage:WaitForChild("Values"):WaitForChild("FoodExist")
local bitting = game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("Bitting")
local Foods = game:GetService("ReplicatedStorage"):WaitForChild("foods"):GetChildren()
local randomFood = Foods[math.random(1, #Foods)]:Clone()
local m6d = Instance.new("Motor6D")
local bites = randomFood:FindFirstChild("Bites")
randomFood.Parent = plr.Character
m6d.Parent = randomFood
randomFood.CFrame = plr.Character:FindFirstChild("HumanoidRootPart").CFrame * CFrame.new(0, 4, -7.5)
m6d.Part0 = plr.Character:FindFirstChild("HumanoidRootPart")
m6d.Part1 = randomFood
bitting:FireClient(plr, randomFood)
end
NewFood()
nextFood.OnServerEvent:Connect(function()
NewFood()
end)
end
Local:
local connection
connection = bitting.OnClientEvent:Connect(function(Food)
clicker.Enabled = true
Click.MouseButton1Click:Connect(function()
local bites = Food:FindFirstChild("Bites")
Click.Position = UDim2.new(r:NextNumber(0,1),0,r:NextNumber(0,1),0)
bites.Value = bites.Value - 1
if Food:FindFirstChild("Bites").Value <= 0 then
Food:Destroy()
nextFood:FireServer()
clicker.Enabled = false
connection:Disconnect()
end
end)
end)
And thanks for viewing my issue.