Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Script used to work, stopped working?

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.

1 comment

0

Urgh, months with no answer

1 answer

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)

2 comments

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.

0

It seems to simply not connect, I don't even know.

This discussion is preserved as it was. New answers, comments, and votes are closed.