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

TYCOON WORK 0005 AND 0006: Glitchy exploder and CFraming almost only in studio?

Asked by
davness 376 Moderation Voter
9 years ago

Question 0005

I was creating a tycoon, and with it, a Mineral Producer. It was supposed to explode and leave all parts and unions black and on fire, but it does not work properly. It still kills unions and parts inside of models, and after the 20 seconds after the explosion, the model is not removed. Can someone help me? Script below:

local DrillMaxTemp = script.Parent.DrillMaxTemperature
local DrillTemp = script.Parent.DrillTemperature
local Fan = script.Parent.FanSpeed
local Safety = script.Parent.HasSafetySystem
local Hull = script.Parent.HullPoints
local On = script.Parent.IsMachineOn
local MaxStorage = script.Parent.MaximumStorage
local CurrentStorage = script.Parent.MineStorage
local Mining = script.Parent.MiningSpeed
local Heat = script.Parent.HeatGeneration

while true do
    if CurrentStorage.Value < MaxStorage.Value and On.Value then
        wait(3)
        script.Parent.MineStorage.Value = script.Parent.MineStorage.Value + script.Parent.MiningSpeed.Value
        DrillTemp.Value = DrillTemp.Value + ((Heat.Value - Fan.Value - 150)/1000)
        if DrillMaxTemp.Value > DrillTemp.Value and DrillTemp.Value >= 0.9 * DrillMaxTemp.Value and Safety.Value then
            repeat
                wait(2)
                DrillTemp.Value = DrillTemp.Value + (( - Fan.Value - 150)/1000)
            until DrillMaxTemp.Value > DrillTemp.Value >= 0.75 * DrillMaxTemp.Value
        elseif DrillMaxTemp.Value < DrillTemp.Value then
            for i,v in pairs(script.Parent:GetChildren()) do
                if v.ClassName == "Part" then
                    v.Anchored = false
                    v.BrickColor = BrickColor.Black()
                    v:BreakJoints()
                    local f = Instance.new("Fire", v)
                    f.Size = 30
                    f.Heat = 25
                elseif v.ClassName == "UnionOperation" then
                    v.UsePartColor = true
                    v.Anchored = false
                    v.BrickColor = BrickColor.Black()
                    v:BreakJoints()
                    local f = Instance.new("Fire", v)
                    f.Size = 30
                    f.Heat = 25
                elseif v.ClassName == "Model" then
                    for m,r in pairs (v:GetChildren()) do
                        if r.ClassName == "Part" then
                            r.Anchored = false
                            r.BrickColor = BrickColor.Black()
                            r:BreakJoints()
                            local f = Instance.new("Fire", r)
                            f.Size = 30
                            f.Heat = 25
                        else r:Destroy()
                        end
                    end
                else v:Destroy()
                end
            end
            local expl = Instance.new("Explosion", script.Parent["Your Storage: "..script.Parent.MineStorage.Value.."/"..script.Parent.MaximumStorage.Value].Drill)
            expl.BlastRadius = 500000
            expl.BlastPressure = 1000000000
            wait (20)
            script.Parent:Destroy()
        end
    elseif On.Value then
    DrillTemp.Value = DrillTemp.Value + ((- Fan.Value - 150)/1000)
    wait(2)
    script.Parent.MineStorage.Value = script.Parent.MaximumStorage.Value
    else
    DrillTemp.Value = DrillTemp.Value + ((- Fan.Value - 150)/1000)
    wait(2)
    end
wait(1)
end

When I runned the script and exploded the machine, i got this error:

Workspace.Model.Melt Metal.Factory.MineralProducer.Producer:54: attempt to index field 'Parent' (a nil value)

EDIT: I could solve the glitch by myself. I also created some speaks so the NPC could talk with the owner about that. Script below for who wants to learn:

local DrillMaxTemp = script.Parent.DrillMaxTemperature
local DrillTemp = script.Parent.DrillTemperature
local Fan = script.Parent.FanSpeed
local Safety = script.Parent.HasSafetySystem
local Hull = script.Parent.HullPoints
local On = script.Parent.IsMachineOn
local MaxStorage = script.Parent.MaximumStorage
local CurrentStorage = script.Parent.MineStorage
local Mining = script.Parent.MiningSpeed
local Heat = script.Parent.HeatGeneration
--gets the values


while true do
    if CurrentStorage.Value < MaxStorage.Value and On.Value then -- if there is storage space and the machine is on
        wait(2)
        CurrentStorage.Value = CurrentStorage.Value + Mining.Value -- add mineral to the storage
        DrillTemp.Value = DrillTemp.Value + ((Heat.Value - Fan.Value - 150)/1000) -- heats up the drill
        if DrillMaxTemp.Value > DrillTemp.Value and DrillTemp.Value >= 0.9 * DrillMaxTemp.Value and Safety.Value then -- check if the drill is about 90% of maximum temperature and if there's an safety system
            repeat
                wait(3)
                DrillTemp.Value = DrillTemp.Value + (( - Fan.Value - 150)/1000) -- cooldown the machine until the machine is 75% heated
            until DrillMaxTemp.Value > DrillTemp.Value >= 0.75 * DrillMaxTemp.Value
        elseif DrillMaxTemp.Value < DrillTemp.Value then -- if the machine is too hot then explode
            for i,v in pairs(script.Parent:GetChildren()) do -- get all machine childs
                print (v.ClassName)
                    if v.ClassName == "Model" then -- if the analyzed child is a model then check its childs and create an explosion
                        local expl = Instance.new("Explosion", v.Drill)
                        expl.Position = v.Drill.Position
                        expl.BlastRadius = 5
                        expl.BlastPressure = 1000000    
                        for m,r in pairs (v:GetChildren()) do
                            if r:IsA("BasePart") then -- if the analyzed object is a part or union then burn it
                                r.Anchored = false
                                r.BrickColor = BrickColor.Black()
                                r:BreakJoints()
                                local f = Instance.new("Fire", r)
                                f.Size = 30
                                f.Heat = 25
                            else r:Destroy() -- if the object is something like an humanoid or script then clear it
                        end
                    end
                elseif v ~= script then v:Destroy() -- if it is not a model nor the current script then destroy it
                end
            end
            wait (5)
        local c = game:GetService("Chat") -- chat with the user
        c:Chat(script.Parent.Parent.Parent.Parent["Stevyl Karol"].Head, script.Parent.Parent.Parent.OwnerShipSystem.Owner.Value..", I need to talk with you, quickly!", "Red")
        wait(3)
        c:Chat(game.Workspace:FindFirstChild(script.Parent.Parent.Parent.OwnerShipSystem.Owner.Value).Head,"Man, what's up?", "Red")
        wait(3)
        c:Chat(script.Parent.Parent.Parent.Parent["Stevyl Karol"].Head, "Being sincerly, YOU DESTROYED THE MINING MACHINE!!!!", "Red")
        wait(3)
        c:Chat(game.Workspace:FindFirstChild(script.Parent.Parent.Parent.OwnerShipSystem.Owner.Value).Head,"Yay!!", "Red")
        wait(3)
        c:Chat(script.Parent.Parent.Parent.Parent["Stevyl Karol"].Head, "That's not a easy decision, but... you're fired.", "Red")
        wait(3)
        script.Parent:Destroy() -- destroy the machine
        end
    elseif On.Value then -- if the machine is ON but the system is full then just cooldown the machine
    DrillTemp.Value = DrillTemp.Value + ((- Fan.Value - 150)/1000)
    wait(2)
    script.Parent.MineStorage.Value = script.Parent.MaximumStorage.Value -- equal the storage to maxstorage
    else -- if the machine is turned off then just cooldown
    DrillTemp.Value = DrillTemp.Value + ((- Fan.Value - 150)/1000)
    wait(2)
    end
wait(1) -- give time to check if any propety has changed
end

Question 0006

I've made a script for a fan (a fan like the ones you have on your computer, but much bigger), so it will spin according of the fanspeed set in a value. Script below:

while true do
    script.Parent.CFrame = CFrame.new(script.Parent.CFrame.p)*CFrame.Angles(math.rad(script.Parent.Rotation.X), math.rad(script.Parent.Rotation.Y) + math.rad(tonumber(script.Parent.Parent.Parent.FanSpeed.Value)*360/60/30),math.rad(script.Parent.Rotation.X))
    wait()
end

When runned, it looks the fan is stuck somewhere, and even more stuck when runned on a server. Why?

0
Why are you numbering those questions? Are you making a series on purpose? Do you have OCD? You can just post them normally like everyone else does. Marios2 360 — 9y
0
yes i am serialyzing them :) davness 376 — 9y
0
and just because i like, if you want you can get the links of 4, 3, 2 and 1 davness 376 — 9y

Answer this question