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

Script used to work, stopped working?

Asked by 9 years ago

Flag placer for an RTS I'm making.

Is in a local script in a tool.

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Tool = script.Parent
local Ready = true
local Flag = game.workspace.WhiteFlag


function click()
    if Ready == true then
    Flag.Position = Mouse.Hit.p + Vector3.new(0,3,0)
    Ready = false
    Flag.Transparency = 0
    wait(0.25)
    Flag.Transparency = 0.25
    wait(0.25)
    Flag.Transparency = 0.5
    wait(0.25)
    Flag.Transparency = 0.75
    wait(0.25)
    Flag.Transparency = 1
    Ready = true



    end
    end

Tool.Activated:connect(click)

Can't see any specific output. Used to work entirely fine, stopped working today when I checked.

0
Urgh, months with no answer Maxwell_Edison 105 — 9y

1 answer

Log in to vote
0
Answered by
Redbullusa 1580 Moderation Voter
9 years ago

Reformat your code with indentations for organization and readability purposes.

The only error I see is on line 5.

Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()
Tool = script.Parent
Ready = true
Flag = game.Workspace.WhiteFlag -- You can either capitalize the "w" in "workspace" or omit "game."
-- Flag = workspace.WhiteFlag

function click()
    if Ready then -- You don't need the "== true." It's like saying "if true == true then," when it can be shortened to "if true then"
        Ready = false -- Re-positioned this, just in case
        Flag.Position = Mouse.Hit.p + Vector3.new(0,3,0)
        --[[ Use a "for" loop instead!
        Flag.Transparency = 0
        wait(0.25)
        Flag.Transparency = 0.25
        wait(0.25)
        Flag.Transparency = 0.5
        wait(0.25)
        Flag.Transparency = 0.75
        wait(0.25)
        Flag.Transparency = 1
        ]]
        for i = 0, 1, .25 do
            Flag.Transparency = i
            wait(.25)
        end 
        -- Compare the 9-lined code to the 4-lined code from the "for" loop. Imagine if you wanted to do smaller increments on the transparency. That 9-lined code will stretch, while the 4-lined code will stay the same. o.e
        Ready = true
    end
end

Tool.Activated:connect(click)
0
Thanks, but capitalization was the first thing I checked. It still doesn't work with absolutely no errors, something I think no amount of fancy scripting will fix. Maxwell_Edison 105 — 9y
0
It seems to simply not connect, I don't even know. Maxwell_Edison 105 — 9y
Ad

Answer this question