User:Outofspace/ON-OFF Button: Difference between revisions
From Legacy Roblox Wiki
Jump to navigationJump to search
>Outofspace No edit summary |
>Outofspace No edit summary |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
Here are a few On/Off scripts/tools that you can use. | |||
__TOC__ | |||
==The Script== | |||
Changes the skybox from night to day. | |||
<pre> | <pre> | ||
--On/Off Button | |||
--OutOfSpace | |||
--1.0b | |||
script.Name = "On/Off-Script_Version_1.0b" | |||
script.Parent = game.Workspace | |||
a = game.Workspace:GetChildren() | |||
for i = 1, #a do | |||
if a[i].Name == script.Name then | |||
a[i]:Remove() | |||
end | |||
end | end | ||
function | local b = Instance.new("Part") | ||
b.Parent = game.Workspace | |||
b.Name = "Head" | |||
b.Size = Vector3.new(5, 1 ,5) | |||
local m = Instance.new("Model") | |||
m.Parent = game.Workspace | |||
m.Name = "Waiting..." | |||
b.Parent = m | |||
local h = Instance.new("Humanoid") | |||
h.Parent = m | |||
local c = Instance.new("ClickDetector") | |||
c.Parent = b | |||
c.MaxActivationDistance = 100 | |||
local s = Instance.new("Script") | |||
s.Parent = game.Workspace | |||
s.Disabled = true | |||
s.Name = "ButtonScript" | |||
s.Source = [[ | |||
script.Parent.Parent.Name = "On" | |||
local isOn = true | |||
function on() | |||
isOn = true | |||
game.Workspace.On.Head.BrickColor = BrickColor.new(21) | |||
game.Lighting.TimeOfDay = "00:00:00" | |||
game.Workspace.On.Name = "Off" | |||
end | |||
function off() | |||
isOn = false | |||
game.Workspace.Off.Head.BrickColor = BrickColor.new(28) | |||
game.Lighting.TimeOfDay = "14:00:00" | |||
game.Workspace.Off.Name = "On" | |||
end | |||
function onClicked() | |||
if isOn == true then off() else on() end | |||
end | end | ||
script.Parent. | script.Parent.ClickDetector.MouseClick:connect(onClicked) | ||
on() | |||
]] | |||
s.Disabled = false | |||
sad = s:clone() | |||
s:Remove() | |||
sad.Parent = b | |||
</pre> | </pre> | ||
Latest revision as of 03:11, 15 December 2008
Here are a few On/Off scripts/tools that you can use.
The Script
Changes the skybox from night to day.
--On/Off Button --OutOfSpace --1.0b script.Name = "On/Off-Script_Version_1.0b" script.Parent = game.Workspace a = game.Workspace:GetChildren() for i = 1, #a do if a[i].Name == script.Name then a[i]:Remove() end end local b = Instance.new("Part") b.Parent = game.Workspace b.Name = "Head" b.Size = Vector3.new(5, 1 ,5) local m = Instance.new("Model") m.Parent = game.Workspace m.Name = "Waiting..." b.Parent = m local h = Instance.new("Humanoid") h.Parent = m local c = Instance.new("ClickDetector") c.Parent = b c.MaxActivationDistance = 100 local s = Instance.new("Script") s.Parent = game.Workspace s.Disabled = true s.Name = "ButtonScript" s.Source = [[ script.Parent.Parent.Name = "On" local isOn = true function on() isOn = true game.Workspace.On.Head.BrickColor = BrickColor.new(21) game.Lighting.TimeOfDay = "00:00:00" game.Workspace.On.Name = "Off" end function off() isOn = false game.Workspace.Off.Head.BrickColor = BrickColor.new(28) game.Lighting.TimeOfDay = "14:00:00" game.Workspace.Off.Name = "On" end function onClicked() if isOn == true then off() else on() end end script.Parent.ClickDetector.MouseClick:connect(onClicked) on() ]] s.Disabled = false sad = s:clone() s:Remove() sad.Parent = b