My script no work :c

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 :frowning:

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)
3 Likes

what is the error of the output? or it doesnt doesnt work and doesnt give errors

noo friend there no errors empty as my brain !!

1 Like

Instead of using that, you should use

smoke.Parent

And ParticleEmitters are usually more efficient considering you have more customization options,
and they can be easily enabled and disabled.

doesn’t work :frowning:

11111111111111111111111

You need to connect it AFTER the function, or else it won’t call.
Example

function Functionnamehere(whatever)
print("Function here")
end

object.Event:connect(Functionnamehere)

I believe this is because it is trying to connect to a function that doesn’t exist.

like this ?:

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

object.Event:connect(Functionnamehere)

Yes that would be about right.

ok thank you i try it now

1111111111111

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)


1 Like

thank you :slight_smile:

11111111111111111111

And @RedOver133

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.

didn’t understand
111111111111111111111111111

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)
1 Like

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.

1 Like