Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to add smoke to vip player's body on join?

Hi, i'm trying to add smoke to player's torso when players who have bought my vip gamepass have joined the game. i am currently using this script but i am not done with it.

local GamePassService = Game:GetService('GamePassService')
local GamePassIdObject = WaitForChild(script, 'GamePassId')

local function OnPlayerAdded(player)
	if GamePassService:PlayerHasPass(player, GamePassIdObject.Value) then
		--script that adds smoke to the body here
	end	


2 answers

✓ Accepted answer

You'd then use the CharacterAdded event of the Player to create a new smoke instance inside of the character's torso every time the player spawns.

local GamePassService = Game:GetService('GamePassService')
local GamePassIdObject = WaitForChild(script, 'GamePassId')

local function OnCharacterAdded(char)
	local smoke = Instance.new("Smoke", char:WaitForChild("Torso"))
	smoke.Color = Color3.new(1, 0, 0) -- red, remember to use 0-1 and not 0-255. If you want to use 0-255, just make sure to divide each number by 255.
	smoke.Size = 5
end

local function OnPlayerAdded(player)
	if GamePassService:PlayerHasPass(player, GamePassIdObject.Value) then
		player.CharacterAdded:connect(OnCharacterAdded)
	end
end

Game:GetService("Players").PlayerAdded:connect(OnPlayerAdded)

6 comments

0

The smoke didn't appear when i started the game, the output was this --- 17:14:54.957 - Workspace.vip smoke:2: attempt to call global 'WaitForChild' (a nil value) 17:14:54.957 - Stack Begin 17:14:54.958 - Script 'Workspace.vip smoke', Line 2 17:14:54.958 - Stack End --- @ Ekkoh 

1

That is from your code -- it should be your problem to solve. . . Use script:WaitForChild("GamePassId") instead.

0

I suggest studying anonymous function. It could shorten code considerably and make it easier for the community to read, getting you more answers faster.

0

thank you it worked but just one more question if its not to much, how do i configure the smoke if i want it to be red, or bigger. @BlueTaslem @GoldenPhysics

0

Made an edit :)

0

Thank you Ekkoh

id = 000000 -- Put the id of the GamePass Here

game.Players.PlayerAdded:connect(function(plr)
	if game:GetService('GamePassService'):PlayerHasPass(plr, id) then
		plr.CharacterAdded:connect(function(char)
			c = plr.Character:GetChildren()
			for i = 1,#c do
				if c[i]:IsA("BasePart") then
					for i = 1,5 do
						s = Instance.new("Smoke", plr.Character.Torso)
					end
				end
			end
		end)
	end
end)

You just need to put the smoke instance into the player. This will put 5 smoke instances into each Part of the Character.

Hope I Helped

+1

2 comments

0

"game.Workspace:FindFirstChild(plr, true).Torso" won't work. Even if your script did work and was a good way to do it, it would only be applied the first time the character spawns.

0

I derped.. Edited tho :3

This discussion is preserved as it was. New answers, comments, and votes are closed.