I have a few grills, but when I activate one, it activates both. Here is the script:
local CollectionService = game:GetService("CollectionService")
local Grills = CollectionService:GetTagged("Grill")
local playerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local cookingGui = playerGui:WaitForChild("CookingGUI")
local cookingGuiFrame = cookingGui:WaitForChild("CookingGUIFrame")
local selectedGrill
for i, grill in pairs(Grills) do
grill.Grill.CookPrompt.Triggered:Connect(function(plr)
if plr == game.Players.LocalPlayer then
selectedGrill = grill
cookingGuiFrame.Visible = true
end
end)
break
end
cookingGuiFrame.Desserts.Baklava.MouseButton1Click:Connect(function()
cookingGuiFrame.Visible = false
game.ReplicatedStorage.FireDesserts.FireBaklava:FireServer(selectedGrill)
end)
I believe because it is getting any object tagged with Grill in it:
Do you have another script that has tagged these objects as Grill?
Per Roblox:
The CollectionService manages groups (collections) of instances with tags. Tags are sets of strings applied to objects that replicate from the server to the client and in Team Create. They are also serialized when places are saved. At the moment, tags are not visible within Roblox Studio except with the use of a tag-editing plugin.
I think I figured out the issue. The problem is not with the script I have shown above, but it is with the server script that is animating the grill. The specific part is where it waits to see if the remote event has been fired, and if it has, it will call a function. Here is the code:
local function fridgeThenOven(plr,grill)
local character = plr.Character
if not character or not character.Parent then
character = plr.CharacterAdded:Wait()
end
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local useOven = Instance.new("Animation")
useOven.AnimationId = "rbxassetid://9239038063"
local useOvenTrack = animator:LoadAnimation(useOven)
local grabFromFridge = Instance.new("Animation")
grabFromFridge.AnimationId = "rbxassetid://9232237218"
local grabFromFridgeTrack = animator:LoadAnimation(grabFromFridge)
local humanoidRootPart = plr.Character.HumanoidRootPart
humanoidRootPart.Anchored = true
openFridge:Play()
wait(1.4)
grabFromFridgeTrack:Play()
wait(3.4)
closeFridge:Play()
wait(1.4)
ovenHeat.Transparency = 0.6
openOven:Play()
wait(1.4)
useOvenTrack:Play()
wait(3.4)
closeOven:Play()
wait(3)
openOven:Play()
wait(1.4)
useOvenTrack:Play()
wait(3.4)
closeOven:Play()
ovenHeat.Transparency = 1
humanoidRootPart.Anchored = false
end
game.ReplicatedStorage.FireDesserts.FireBaklava.OnServerEvent:Connect(fridgeThenOven)
In the script I first showed, it is firing the remote event and sending the parameter, selectedGrill. The grill script isn’t checking to see if it is the selected grill. This is an easy fix. All I have to do is add an if then statement in each function so it will only run if the grill parameter of the function is the grill the script is inside of.