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

Scripts will not run when moved from replicated to work space. How to fix? [Solved]

Asked by
J_Deku 0
3 years ago
Edited by greatneil80 3 years ago

Hi

So I have a powers script that turns the character basically into a nuclear bomb under development

I use module scripts to store the functions that generate the parts for the effects, the parts get made, dumped into replicated then cloned from replicated and moved into the workspace The same happens to premade meshes The meshes get parented to the parts and then this is where the scripts come in. All they do is animated the particle effects by adjusting there size, transparency etc.

They are moved from replicated into the workspace parented under the mesh of the corresponding effect. So the hierarchy looks a little bit like this:

Object > Mesh > Script

However the script does nothing when parented to the mesh. It doesn't even run the print at the top of the script The scripts:

Main local:

wait(1)
local Player = game.Players.LocalPlayer
local Char = Player.Character
local Mouse = Player:GetMouse()
local Parts = require(game.ReplicatedStorage.Nuclear.Move1.Parts)
local Part = Instance.new("Part")
local Move1 = require(game.ReplicatedStorage.Nuclear.Move1)
game:GetService("UserInputService").InputBegan:connect(function(input)
    if input.KeyCode == Enum.KeyCode.Z then
        print("Spawning")
        Move1.PartMake()
        Move1.Parenting()
        Move1.Rename()
    end
end)

Module Move1

local Move1 = {}
local Parts = require(game.ReplicatedStorage.Nuclear.Move1.Parts)
local Meshes = require(game.ReplicatedStorage.Nuclear.Move1.Parts)
local Part1 = Instance.new("Part")
local Part2 = Instance.new("Part")
local Part3 = Instance.new("Part")
local Part4 = Instance.new("Part")
local Nuclear = game.ReplicatedStorage.Nuclear
local whiteringmesh = Nuclear.Meshes.whitering
local blackringmesh = Nuclear.Meshes.blackring
local Player = game:GetService("Players").LocalPlayer
local SAnim = Nuclear["Anim Scripts"]
Move1.PartMake = function(player)

    Part1.Name = Parts.whitering[1]
    Part1.Size = Vector3.new(Parts.whitering[2], Parts.whitering[3], Parts.whitering[4])
    Part1.Position = Vector3.new(Parts.whitering[5], Parts.whitering[6], Parts.whitering[7])

    Part1.Color = Color3.new(Parts.whitering[11], Parts.whitering[12], Parts.whitering[13])
    Part1.Material = Parts.whitering[14]
    Part1.CastShadow = Parts.whitering[15]
    Part1.CanCollide = Parts.whitering[16]
    Part1.Anchored = Parts.whitering[17]
    Part2.Name = Parts.blackring[1]
    Part2.Size = Vector3.new(Parts.blackring[2], Parts.blackring[3], Parts.blackring[4])
    Part2.Position = Vector3.new(Parts.blackring[5], Parts.blackring[6], Parts.blackring[7])

    Part2.Color = Color3.new(Parts.blackring[11], Parts.blackring[12], Parts.blackring[13])
    Part2.Material = Parts.blackring[14]
    Part2.CastShadow = Parts.blackring[15]
    Part2.CanCollide = Parts.blackring[16]
    Part2.Anchored = Parts.whitering[17]
    Part1.Parent = Nuclear.Parts
    Part2.Parent = Nuclear.Parts
end
Move1.Parenting = function(player)
    local wr = Nuclear.Parts.whitering:Clone()
    local br = Nuclear.Parts.blackring:Clone()
    local wrm = whiteringmesh:Clone()
    local brm = blackringmesh:Clone()
    local wa = SAnim.whiteringA:Clone()
    local ba = SAnim.blackringA:Clone()
    wr.Parent = workspace
    br.Parent = workspace
    wrm.Parent = workspace.whitering
    brm.Parent = workspace.blackring
    workspace.whitering.CFrame = Player.Character.LeftFoot.CFrame
    workspace.blackring.CFrame = Player.Character.LeftFoot.CFrame
    workspace.whitering.Orientation = Vector3.new(Parts.whitering[8], Parts.whitering[9], Parts.whitering[10])
    workspace.blackring.Orientation = Vector3.new(Parts.blackring[8], Parts.blackring[9], Parts.blackring[10]) 
    wa.Disabled = false
    ba.Disabled = false
    wa.Parent = workspace
    ba.Parent = workspace
    workspace.whiteringA.Parent = workspace.whitering.whitering
    workspace.blackringA.Parent = workspace.blackring.blackring
end
Move1.Rename = function(rename)
    workspace.whitering.whitering.Name = "Random_Part:".. math.random(4000, 400000)
    workspace.blackring.blackring.Name = "Random_Part:".. math.random(4000, 400000)
    workspace.whitering.Name = "Random_Part:".. math.random(4000, 400000)
    workspace.blackring.Name = "Random_Part:".. math.random(4000, 400000)
end
return Move1

Parts


local Parts = { -- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 --Name Size Position Orientation Color Material CastShadow Can collide Anchored whitering = {"whitering", 15, 15, 2, -58.977, 8.5, -48.573, 90, 0, 0, 163, 162 , 165, "Plastic", false, false, true}, blackring = {"blackring", 1, 0.2, 1, -66.026, 2.7, -113.147, 90, 0, 0, 99, 95, 98, "Plastic", false, false, true} } return Parts

whiteringA

print("This is the white ring anim script")
local obj = script.Parent
local Player = game.Players.LocalPlayer

local Audio = Instance.new("Sound")
local Audio2 = Instance.new("Sound")

Audio.SoundId = "rbxassetid://181004943"
Audio.Name = "Charge"
Audio.Volume = 1
Audio.Pitch = 1
Audio.Parent = Player.PlayerGui
Audio:Play()

wait(0.2)

Audio2.SoundId = "rbxassetid://1332996017"
Audio2.Name = "NuclearExplosion"
Audio2.Volume = 1
Audio2.Pitch = 1
Audio2.Parent = Player.PlayerGui
Audio2:Play(wait(0.6))

repeat wait(0.1)
    obj.Scale = obj.Scale + Vector3.new(-1, -1, -0.6)
until obj.Scale.Y <= 5

repeat wait(0.1)

    obj.Scale = obj.Scale + Vector3.new(3, 3, 1.8)
    obj.Parent.Transparency = obj.Parent.Transparency + 0.010
    obj.Parent.Size = obj.Parent.Size + Vector3.new(3, 3, 0)

until obj.Parent.Transparency >= 1 
print("Whitering anim script complete")
    script.Parent.Parent:Destroy()
end)


blackringA

wait(0.2)
local obj = script.Parent

repeat wait(0.1)
    obj.Scale = obj.Scale + Vector3.new(-1, -1, -0.6)
until obj.Scale.Y <= 5

repeat wait(0.1)

    obj.Scale = obj.Scale + Vector3.new(4, 4, 2.4)
    obj.Parent.Transparency = obj.Parent.Transparency + 0.010


until obj.Parent.Transparency >= 1 

script.Parent.Parent:Destroy()


I get no response from the bottom two. Not even a print or an error

Could anyone help me understand where I've gone wrong or what I'm missing to get this working?

Thanks!

1 answer

Log in to vote
0
Answered by
J_Deku 0
3 years ago

NVM I got it.

The reason was is because i was cloning a server script with a local script. Which causes Server scripts to be unable to run. So a remote event, a server script and alot of code later. Its working as expected now

0
good job. Marking this question as solved greatneil80 2647 — 3y
Ad

Answer this question