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

How to make radio display particles with emitter ?

Asked by
Bulvyte 388 Moderation Voter
8 years ago

So i got my own decal for Particle Emitter and what i want to do when player presses play the particles emit and when stops i want it to stop emitting. y doesn't it work ?

wait(0.1)
local sound = Instance.new("Sound")
sound.Volume=1
sound.Pitch=1
sound.Name=""
sound.Looped=true
sound.PlayOnRemove=false
local player = game.Players.LocalPlayer.Character
sound.Parent = player.Radio
local Format = "http://www.roblox.com/asset/?id=##ID##"
local frame = script.Parent:WaitForChild("Frame")
Spark = script.Parent.Parent.ParticleEmitter

frame:WaitForChild("Play").MouseButton1Click:connect(function()
    local input = tonumber(frame:WaitForChild("Input").Text)
    if input then
        sound:Stop()
        sound.SoundId=Format:gsub("##ID##", tostring(input))
        sound:Play()
        Spark:Enabled()
    end
end)
frame:WaitForChild("Stop").MouseButton1Click:connect(function()
    sound:Stop()
    Spark:Enabled()
end)

help

1 answer

Log in to vote
0
Answered by 8 years ago

From a first glance, you aren't turning on and off the particle emitter in a valid way. Enabled() is not a default function of Particle emitter, meaning it won't do anything and might return an error.

In order to turn a particle emitter on or off, you need to set the boolean property "Enabled" to true or false respectively.

So instead of Spark:Enabled(), use this to turn it on,

Spark.Enabled = true

and this to turn it off

Spark.Enabled = false

Thus the final product would look like

wait(0.1)
local sound = Instance.new("Sound")
sound.Volume=1
sound.Pitch=1
sound.Name=""
sound.Looped=true
sound.PlayOnRemove=false
local player = game.Players.LocalPlayer.Character
sound.Parent = player.Radio
local Format = "http://www.roblox.com/asset/?id=##ID##"
local frame = script.Parent:WaitForChild("Frame")
Spark = player:WaitForChild("Radio").ParticleEmitter

frame:WaitForChild("Play").MouseButton1Click:connect(function()
    local input = tonumber(frame:WaitForChild("Input").Text)
    if input then
        sound:Stop()
        sound.SoundId=Format:gsub("##ID##", tostring(input))
        sound:Play()
        Spark.Enabled = true
    end
end)
frame:WaitForChild("Stop").MouseButton1Click:connect(function()
    sound:Stop()
    Spark.Enabled = false
end)

0
I haven't tested this yet, but how do you see script errors log? Bulvyte 388 — 8y
0
If you are testing this in roblox Studio, go to "View" and click output window. Else, you could hit f9 in a game and click on "Server console". Errors will be in red randomsmileyface 375 — 8y
0
It doesn't work when player joins the particles are in Radio which means in his inventory and script locates that it's in script.Parent.Parent.ParticleEmitter which means in radio but it locates that in playergui how i locate the radio which is in players inventory ??? Bulvyte 388 — 8y
0
game.Players.LocalPlayer.Backpack.Radio randomsmileyface 375 — 8y
View all comments (12 more)
0
The radio is in game.workspace.Player1 which means when any random name is there i dont know how to locate it. the player1 name im testing in solo and in backpack theres nothing actually Bulvyte 388 — 8y
0
http://prntscr.com/88s9gz there how it looks its not in Services like Players > Player > Backpack its in workspace. how 2 locate it ? Bulvyte 388 — 8y
0
I was under the assumption that by "Inventory", you meant the player's backpack. In that case, You've already defined your player, which won't change even if his name isn't Player1. Look at this segment --local player = game.Players.LocalPlayer.Character-- It defines the model Player1 as the variable player. Thus, radio is player.Radio randomsmileyface 375 — 8y
0
Yes but can you make the script enable the particles when its playing and atop when its stopped on clicks? Please? Bulvyte 388 — 8y
0
I updated the answer with the code. If it produces any error, please tell me what it is randomsmileyface 375 — 8y
0
"Did you forget a colon? The first argument of member function WaitChild must... thats what i got Bulvyte 388 — 8y
0
oops. Yeah. Common error on my part. it should be Spark = player.WaitForChild("Radio").ParticleEmitter randomsmileyface 375 — 8y
0
I mean Spark = player:WaitForChild("Radio").ParticleEmitter So frustrating randomsmileyface 375 — 8y
0
Man it still doesn't work... Bulvyte 388 — 8y
0
ParticleEmitter is not a valid member of Part... .-. Bulvyte 388 — 8y
0
Tell me the error this time... randomsmileyface 375 — 8y
0
NEVERMIND I FIXED IT Spark = player.Radio.ParticleEmitter THATS WHAT I WROTE THX!!! ANYWAY :3 Bulvyte 388 — 8y
Ad

Answer this question