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

script won't work even if value == true?

SORRY FOR THE LONG SCRIPT! everything works except the if game.Workspace.bgk.Value == true then line, anyone know why? i need this to only work if the value is true, please help me

local debris = game:service("Debris")
bin = script.Parent
Go = 0

Kick = false
function onKeyDown(key)
if game.Workspace.bgk.Value == true then 
if Go.Value == 1 then return end
if key ~= nil then
key = key:lower()
if key == "e" then
Go = 1
if script.Parent.Parent.Parent.Character == nil then return end
if script.Parent.Parent.Parent.Character:findFirstChild("Torso") == nil then return end
if script.Parent.Parent.Parent.Character:findFirstChild("Right Arm") == nil then return end
if script.Parent.Parent.Parent.Character:findFirstChild("Left Arm") == nil then return end
if script.Parent.Parent.Parent.Character:findFirstChild("Right Leg") == nil then return end
if script.Parent.Parent.Parent.Character:findFirstChild("Left Leg") == nil then return end
Torso = script.Parent.Parent.Parent.Character.Torso
RA = script.Parent.Parent.Parent.Character["Right Arm"]
LA = script.Parent.Parent.Parent.Character["Left Arm"]
RL = script.Parent.Parent.Parent.Character["Right Leg"]
LL = script.Parent.Parent.Parent.Character["Left Leg"]
Hip = Torso["Right Shoulder"]
Hip.Part1 = nil
Hip1 = Torso["Left Shoulder"]
Hip1.Part1 = nil
HipL = Torso["Right Hip"]
HipL.Part1 = nil
HipL1 = Torso["Left Hip"]
HipL1.Part1 = nil
W = Instance.new("Weld")
W.Parent = RA
W.Part0 = Torso
W.Part1 = RA
Y = Instance.new("Weld")
Y.Parent = LA
Y.Part0 = Torso
Y.Part1 = LA
U = Instance.new("Weld")
U.Parent = RL
U.Part0 = Torso
U.Part1 = RL
T = Instance.new("Weld")
T.Parent = LL
T.Part0 = Torso
T.Part1 = LL
Kick = true
script.Parent.Parent.Parent.Character.Humanoid.WalkSpeed = 17
script.Parent.Parent.Parent.Character.Torso.Friction = "1"
script.Parent.Parent.Parent.Character["Left Arm"].Friction = "2"
script.Parent.Parent.Parent.Character["Right Arm"].Friction = "2"
script.Parent.Parent.Parent.Character["Left Leg"].Friction = "1"
script.Parent.Parent.Parent.Character["Right Leg"].Friction = "1"
W.C0 = CFrame.new(1.8,0.3,0.1) * CFrame.fromEulerAnglesXYZ(math.pi/6,-0.5,1)
Y.C0 = CFrame.new(-1.8,0.3,0.1) * CFrame.fromEulerAnglesXYZ(math.pi/6,0.5,-1)
U.C0 = CFrame.new(0.9,-1.7,-0.3) * CFrame.fromEulerAnglesXYZ(math.pi/8,-0.2,0.3)
T.C0 = CFrame.new(-0.9,-1.7,-0.3) * CFrame.fromEulerAnglesXYZ(math.pi/8,0.2,-0.3)
RL.Touched:connect(function(hit)
if Kick == false then return end
if hit.Locked == true or hit.Anchored == true then return end
Kick = false
A = Instance.new("BodyVelocity")
A.Parent = hit
A.velocity = RL.CFrame.lookVector * 70
A.maxForce = Vector3.new(4e+006,1e+003,4e+006)
debris:AddItem(A,0.3)
end)
LL.Touched:connect(function(hit)
if Kick == false then return end
if hit.Locked == true or hit.Anchored == true then return end
Kick = false
B = Instance.new("BodyVelocity")
B.Parent = hit
B.velocity = LL.CFrame.lookVector * 70
B.maxForce = Vector3.new(4e+006,1e+003,4e+006)
debris:AddItem(B,0.3)
end)
Torso.Touched:connect(function(hit)
if Kick == false then return end
if hit.Locked == true or hit.Anchored == true then return end
Kick = false
N = Instance.new("BodyVelocity")
N.Parent = hit
N.velocity = Torso.CFrame.lookVector * 70
N.maxForce = Vector3.new(4e+006,1e+003,4e+006)
debris:AddItem(N,0.3)
end)
wait(0.5)
W.C0 = CFrame.new(1.8,1,0.1) * CFrame.fromEulerAnglesXYZ(-math.pi,0,1)
Y.C0 = CFrame.new(-1.8,1,0.1) * CFrame.fromEulerAnglesXYZ(-math.pi,0,-1)
U.C0 = CFrame.new(1.2,-1.7,-0.3) * CFrame.fromEulerAnglesXYZ(math.pi/4,-0.5,0.7)
T.C0 = CFrame.new(-1.2,-1.7,-0.3) * CFrame.fromEulerAnglesXYZ(math.pi/4,0.5,-0.7)
wait(0.5)
Kick = false
W:Remove()
Y:Remove()
U:Remove()
T:Remove()
Hip.Part1 = RA
Hip1.Part1 = LA
HipL.Part1 = RL
HipL1.Part1 = LL
wait(0.2)
Go = 0
end
end
end

bin.Deselected:connect(function()
end)
function onSelected(mouse)
mouse.KeyDown:connect(onKeyDown)
end
end

bin.Selected:connect(onSelected)

1 comment

0

output

1 answer

If you actually formatted the code, you would be able to see that onSelected is only defined inside of the onKeyDown function when it is called, so line 117 cannot access it.

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