my script is about you eat chicken and fart eventually how can i make this work ? shouldn’t my script work? as i am trying to make smoke go in player’s torso but no work
local tool = script.Parent
local handle = tool.Handle
local sound = handle.SmokeSFX
local plr = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local char = plr.CharacterAdded:Wait()
local lowertorso = char:WaitForChild("LowerTorso")
tool.Activated:Connect(function()
local smoke = Instance.new("Smoke", lowertorso)
smoke.Name = "Green"
smoke.Enabled = true
sound:Play()
smoke.Enabled = true
wait(1)
smoke.Enabled = false
end)
local tool = script.Parent
local handle = tool.Handle
local sound = handle.SmokeSFX
local plr = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local char = plr.CharacterAdded:Wait()
local lowertorso = char:WaitForChild("LowerTorso")
function Functionnamehere(whatever)
tool.Activated:Connect(function()
local smoke = Instance.new(“Smoke”)
smoke.Parent = lowertorso
smoke.Name = “Green”
smoke.Enabled = true
sound:Play()
smoke.Enabled = true
wait(1)
smoke.Enabled = false
end)
end
after many screams, i used a way to make this work, basically you messed up the variables but i fixed all
local tool = script.Parent
print("done")
tool.Activated:Connect(function()
--instead of declaring variables at the start, we use them here to simplify
local cha = tool.Parent --the tool is in the character of the player, so Tool.Parent
local lowertorso = cha:WaitForChild("Torso") or cha:WaitForChild("LowerTorso") --so the script will work for both R6 and R15
local smoke = Instance.new("Smoke")
smoke.Parent = lowertorso --never do Instance.new("Smoke",lowertorso) as it is laggy
smoke.Name = "Green"
smoke.Enabled = true
wait(1)
smoke.Enabled = false
end)
Why create smoke every time? If the script is done this way every time you enable it then it’s going to create another Instance of smoke and name it the same.
Create the smoke in the player at the start when the tool is put into the Player.
Just use the script to Enable true and false when you need it.
he is saying that when you create the smoke (fart) doesnt remove and remain the game forever
you can fix this with this line
game.Debris:AddItem(smoke, 2) --this will delete the smoke after 2 seconds
full code:
local tool = script.Parent
print("done")
tool.Activated:Connect(function()
--instead of declaring variables at the start, we use them here to simplify
local cha = tool.Parent --the tool is in the character of the player, so Tool.Parent
local lowertorso = cha:WaitForChild("Torso") or cha:WaitForChild("LowerTorso")
local smoke = Instance.new("Smoke")
smoke.Parent = lowertorso
smoke.Name = "Green"
smoke.Enabled = true
wait(1)
smoke.Enabled = false -- lets wait the smoke disables for a smooth effect
game.Debris:AddItem(smoke, 2)
end)
Like @deaconstjohn03 said.
You are creating an Instance (the smoke) every time the player farts.
It’d be the same as adding a light bulb to a room each time you want to make light instead of adding one light bulb one time and just turning it on and off.
You aren’t checking if the Smoke is already there. If it is there you are creating another Smoke.
If a player farts 100 times there will be 100 instances of Smoke in the player.
Create one Smoke instance in the player when they spawn into the game, but make it Enabled = false.
Every time the player farts make it Enabled = true for task.wait(1) (it’s better than wait(1)) then make it Enabled = false.