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

This scripts works perfectly in studio, but doesn't work in the actual game, how can i solve that?

Asked by
Echtic 128
5 years ago

The script is local and it's located in the starterGUI. I would really appreciate some help on this. Here's the script:

local me = game.Players.iiiAmericanLight
local chr = me.Character
local dg = Instance.new("ParticleEmitter")
dg.Parent = chr:FindFirstChild("Right Arm")
dg.Texture = game.ReplicatedStorage.DemonGlow.Texture
dg.Size = game.ReplicatedStorage.DemonGlow.Size
dg.Speed = game.ReplicatedStorage.DemonGlow.Speed
dg.Color = game.ReplicatedStorage.DemonGlow.Color
dg.LightEmission = game.ReplicatedStorage.DemonGlow.LightEmission
dg.LightInfluence = game.ReplicatedStorage.DemonGlow.LightInfluence
dg.Lifetime = game.ReplicatedStorage.DemonGlow.Lifetime
dg.Rate = game.ReplicatedStorage.DemonGlow.Rate
dg.LockedToPart = true

local dm = Instance.new("Decal")
dm.Name = "dm"
dm.Parent = chr.Head
dm.Texture = game.ReplicatedStorage.DemonMark.Texture
dm.Color3 = game.ReplicatedStorage.DemonMark.Color3

local dt = Instance.new("Part")
dt.Transparency = 1
dt.Size = game.ReplicatedStorage.MarkAuraB.Size 
dt.Parent = chr.Head
dt.CanCollide = false

local weld = Instance.new("Weld")
weld.Part0 = dt
weld.Part1 = chr.Head
weld.C0 = weld.C0*CFrame.new(-0.3, -0.4, 0.45) 
weld.Parent = dt


local ma = Instance.new("ParticleEmitter")
ma.Parent = dt
ma.Size = game.ReplicatedStorage.MarkAura.Size
ma.Lifetime = game.ReplicatedStorage.MarkAura.Lifetime
ma.Rate = game.ReplicatedStorage.MarkAura.Rate
ma.Color = game.ReplicatedStorage.MarkAura.Color
ma.Speed = game.ReplicatedStorage.MarkAura.Speed
ma.LightEmission = game.ReplicatedStorage.MarkAura.LightEmission
ma.LightInfluence = game.ReplicatedStorage.MarkAura.LightInfluence
ma.Texture = game.ReplicatedStorage.MarkAura.Texture
0
It doesn't work for you or other players? User#22219 20 — 5y
0
it is supposed to work only for me, but it doesn't work at all in the game. Echtic 128 — 5y
0
Have you tried putting .Parent last? User#22219 20 — 5y
View all comments (17 more)
0
i'll try that Echtic 128 — 5y
0
Also is Filtering Enabled on? User#22219 20 — 5y
0
it is not Echtic 128 — 5y
0
Can you show us your output please? SulaymanArafat 230 — 5y
0
of course Echtic 128 — 5y
0
If it still doesn't work, press F9 in studio or game, and if there's a error, please report it to me. Note: There are two tabs call "Client Log" and "Server Log", please report both errors to me. Server Log only works on a game, not Roblox Studio. User#22219 20 — 5y
0
Output is F9, by the way. User#22219 20 — 5y
0
nothing in my output Echtic 128 — 5y
0
Also, if the .Color .Lifetime for the ParticleEmitter is not a Value, like a StringValue, then you could clone them, instead of doing it all over again. User#22219 20 — 5y
0
How about put this in the first line: local me = game.Players:FindFirstChild("iiiAmericanLight"), and this in the second line: if me ~= nil then User#22219 20 — 5y
0
local script Echtic 128 — 5y
0
Try adding wait() on top of the script User#22219 20 — 5y
0
did you try my answer SulaymanArafat 230 — 5y
0
it worked <3 Echtic 128 — 5y
0
accept then please <3 SulaymanArafat 230 — 5y
0
the problem was in wait() Echtic 128 — 5y
0
Thanks everyone <3 Echtic 128 — 5y

3 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Maybe you're referencing the character before it actually existed, as characters load after the player is added. Here's how I set my character variable each time the character loads or disappears.

local char = player.Character or player.CharacterAdded:Wait()
0
I suppose the Character might be the problem, you might be right. User#22219 20 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

The error is on lines 1-2. You’re referencing your Player object before it’s added and your Character as well, you shouldn’t do it like this. You should instead use a Players.PlayerAdded event to check if the player is you.

game:GetService('Players').PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        if plr.UserId == 48617255 then -- grabbed your user id lol
            -- Do code.
        end
    end)
end)
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

You can add before the object selected a WaitForChild()

example:

-- The objct you want is a part called : Blue
****
part = game.Workspace:WaitForChild("Blue")

-- WaitForChild() means that the script will continue to wait until he founds an object that correspond to ourdescription, in this case is : "Blue"

You need to do this only when you define an object, you Don't have to do this to define a size, position, ...

Answer this question