Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
DanzLua 2879 Moderation Voter Community Moderator
9 years ago

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

Log in to vote
1
Answered by
Ekkoh 635 Moderation Voter
9 years ago

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)
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  DanzLua 2879 — 9y
1
That is from your code -- it *should* be your problem to solve. . . Use `script:WaitForChild("GamePassId")` instead. BlueTaslem 18071 — 9y
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. GoldenPhysics 474 — 9y
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 DanzLua 2879 — 9y
View all comments (2 more)
0
Made an edit :) Ekkoh 635 — 9y
0
Thank you Ekkoh DanzLua 2879 — 9y
Ad
Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago
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

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. Ekkoh 635 — 9y
0
I derped.. Edited tho :3 Goulstem 8144 — 9y

Answer this question