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

How do I make it so one script CANNOT function until the transparency is set to 0 by another script?

Asked by
vocful 6
4 years ago
Edited 4 years ago

Goal: I would like one script (script A) to allow another script to work (script B) based on transparency.

Problem #1: Is it possible to store my tools in ServerStorage rather than Lighting?

Problem #2: How can I make it so one script CANNOT function until the transparency of it is equal to 0?

Problem #3: Are the booleans false and nil completely alike?

Other Information:

WORKSPACE: Project (folder) -> Functions (folder) -> HammerGiver, HammerOutput, WrenchGiver, WrenchOutput, Planks (grouped model)

LIGHTING: Tools (folder) -> Hammer, Wrench

HAMMER GIVER/INPUT SCRIPT

function OnClick(PersonWhoClicked)
    local y = PersonWhoClicked.Backpack
    local z = game.Lighting.Tools["Hammer"] --hammer stored in "Tools" folder in "Lighting"
    z:Clone().Parent = y --gives hammer to player
    game.Workspace.Project.Functions.HammerGiver:Destroy() --destroys hammer giver
end

script.Parent.ClickDetector.MouseClick:connect(OnClick)

HAMMER OUTPUT SCRIPT

script.Parent.Touched:connect(function(p)
    if p.Parent.Name == "Hammer" then 
        game.Workspace.Project.Functions.HammerOutput.MeshPart.Transparency = 0 --allows the new location of the hammer to be visible
        p.Parent:Destroy() --destroys tool from backpack
        game.Workspace.Project.Functions.Planks.Plank1.Anchored = false --allows wooden plank borders to fall
        game.Workspace.Project.Functions.Planks.Plank2.Anchored = false 
        game.Workspace.Project.Functions.WrenchGiver.MeshPart.Transparency = 0 --reveals next objective or object for game
    end
end)

WRENCH GIVER/INPUT SCRIPT PROBLEM!!!

function OnClick(PersonWhoClicked)
    local y = PersonWhoClicked.Backpack
    local z = game.Lighting.Tools["Wrench"] --gives wrench from "Lighting"
    z:Clone().Parent = y
    game.Workspace.Project.Functions.WrenchGiver:Destroy() --destroys tool giver 
end

script.Parent.ClickDetector.MouseClick:connect(OnClick)

Notes: -hammer transparency is 0 -wrench transparency is 1

POSSIBLE SOLUTIONS 1) How do I make it so the WrenchGiver does not work until the MeshPart transparency is 0? 2) How do I remove the ClickDetector from the WrenchGiver until the MeshPart transparency is 0?

0
Yes you can store the tools in ServerStorage, it is actually recognized as a bad practice to store Instances In Lighting. If the tools are only only referenced via ServerScripts, the tools shall be placed in ServerStorage, otherwise ReplicatedStorage. Secondly, attach :GetPropertyChangedSignal() to the Instance and pass Transparency as the target, Ziffixture 6913 — 4y
0
Set the Disabled boolean to True of the program you wish to not run, then have the Script set it to false upon the Transparency being verified as 0 to immediately run it. Also, no, false and nil are no identical.. in fact, nil is not even a boolean, or even an operand. Ziffixture 6913 — 4y

1 answer

Log in to vote
0
Answered by
vocful 6
4 years ago
Edited 4 years ago

After I set the transparency for the WrenchGiver (input), it doesn't give me the tool, but rather says attempt to call a nil value and I don't know what to do. In the output it states, Attempt to connect failed: Passed value is not a function and it was located in Script 'Workspace.Project.Functions.WrenchGiver.Script', Line 13.

0
Try using uppercase C in Connect? :Connect(function) killerbrenden 1537 — 4y
Ad

Answer this question