generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: why does this not make this true?

Previous Thread :: Next Thread 
Adstract is not online. Adstract
Joined: 13 Sep 2015
Total Posts: 3342
20 Dec 2015 11:53 AM
if playerpress.Value == gamepress.Value then
script.Parent.keypress.keypressedintime.Value = true
else
script.Parent.keypress.keypressedintime.Value = false
end

this is the code, the if statement is TRUE but it won't come out as that

gamepress and playerpress are both string value objects and keypressedintime is a bool value object. i have no idea why this is not setting keypressedintime to true help help

Report Abuse
Adstract is not online. Adstract
Joined: 13 Sep 2015
Total Posts: 3342
20 Dec 2015 12:01 PM
bump this must be an easy solution
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
20 Dec 2015 12:02 PM
Any errors, the script looks fine. Are you sure it's being fired? Try putting in print commands
Report Abuse
Casualist is not online. Casualist
Joined: 26 Jun 2014
Total Posts: 4443
20 Dec 2015 12:02 PM
Where's the rest of function? Likely issue is as soon as they keyUp your function sets it false
Report Abuse
Adstract is not online. Adstract
Joined: 13 Sep 2015
Total Posts: 3342
20 Dec 2015 12:04 PM
there are no errors or anything and everything seems correct.

well here is the whole script:

local function onTouch(human)
local h = human.Parent:findFirstChild("Humanoid")
if gamerunning == false and h ~= nil then
local Human = human.Parent
local racket = Human:findFirstChild("Racket")
local name = h.Parent.Name
h.Name = "Playing"
gamerunning = true
script.Parent.SurfaceGui.TextLabel.Text = "Player 1 is ".. name
if racket ~= nil then
script.Parent.Value.Value = true
end
while script.Parent.Parent.Player2.Value.Value == false and h ~= nil do
wait()
end
if h ~= nil and script.Parent.Parent.Player2.Value.Value == true then
racket.Sounds.Disabled = false
h.Torso.Anchored = true
h.Torso.CFrame = CFrame.new(script.Parent.Parent.T2.Position)
h.WalkSpeed = 0
h.JumpPower = 0
local player = game.Players:FindFirstChild(name)
player.Backpack.PlayCam.Value.Value = 2
player.Backpack.PlayCam.Disabled = false
player.Backpack.Shots.Disabled = false
-- GAME

local pointsp1 = script.Parent.Parent.Player1.Points
local pointsp2 = script.Parent.Parent.Player2.Points
pointsp1.Value = 0
pointsp2.Value = 0
script.Parent.Parent.GameScripts.ShotsP1.Disabled = false
while pointsp1.Value < 11 and pointsp2.Value < 11 do
wait()
local playerpress = player.Backpack.Shots.playerkey
local gamepress = script.Parent.keypress

if playerpress.Value == gamepress.Value then
script.Parent.keypress.keypressedintime.Value = true
else
script.Parent.keypress.keypressedintime.Value = false
end
end
script.Parent.Parent.GameScripts.ShotsP1.Disabled = true

-- GAME

player.Backpack.PlayCam.Disabled = true
player.Backpack.Shots.Disabled = true
player.Backpack.ResetCam.Disabled = false
h.Torso.CFrame = CFrame.new(script.Parent.Parent.SpawnLocation.Position)
h.WalkSpeed = 16
h.JumpPower = 50
h.Name = "Humanoid"
h.Torso.Anchored = false
wait(1)
player.Backpack.ResetCam.Disabled = true
racket.Sounds.Disabled = true
end
script.Parent.Value.Value = false
h.Health = 0
gamerunning = false
script.Parent.Points.Value = 0
script.Parent.SurfaceGui.TextLabel.Text = "Player 1 stand here"
end
end

local function TouchEnd()
if gamerunning == false then
script.Parent.Value.Value = false
end
end

script.Parent.Touched:connect(debounce(onTouch))
script.Parent.TouchEnded:connect(TouchEnd)



and here is the script which changes the keypressed values:

function shotp1()
local randomshot = math.random(1, 4)

if randomshot == 1 then
shuttle = game.Lighting.c1.Shuttles1.f.s1
shuttlefall = game.Lighting.c1.Shuttles1.f.s2
script.Parent.Parent.Player1.keypress.Value = "f"

elseif randomshot == 2 then
shuttle = game.Lighting.c1.Shuttles1.g.s1
shuttlefall = game.Lighting.c1.Shuttles1.g.s2
script.Parent.Parent.Player1.keypress.Value = "g"

elseif randomshot == 3 then
shuttle = game.Lighting.c1.Shuttles1.r.s1
shuttlefall = game.Lighting.c1.Shuttles1.r.s2
script.Parent.Parent.Player1.keypress.Value = "r"

elseif randomshot == 4 then
shuttle = game.Lighting.c1.Shuttles1.t.s1
shuttlefall = game.Lighting.c1.Shuttles1.t.s2
script.Parent.Parent.Player1.keypress.Value = "t"
end

end

function shotp2()
local randomshot = math.random(1, 4)

if randomshot == 1 then
shuttle = game.Lighting.c1.Shuttles2.f.s1
shuttlefall = game.Lighting.c1.Shuttles2.f.s2
script.Parent.Parent.Player2.keypress.Value = "f"

elseif randomshot == 2 then
shuttle = game.Lighting.c1.Shuttles2.g.s1
shuttlefall = game.Lighting.c1.Shuttles2.g.s2
script.Parent.Parent.Player2.keypress.Value = "g"

elseif randomshot == 3 then
shuttle = game.Lighting.c1.Shuttles2.r.s1
shuttlefall = game.Lighting.c1.Shuttles2.r.s2
script.Parent.Parent.Player2.keypress.Value = "r"

elseif randomshot == 4 then
shuttle = game.Lighting.c1.Shuttles2.t.s1
shuttlefall = game.Lighting.c1.Shuttles2.t.s2
script.Parent.Parent.Player2.keypress.Value = "t"
end

end

-- game script
while true do
pointsp1 = script.Parent.Parent.Player1.Points
pointsp2 = script.Parent.Parent.Player2.Points
while pointsp1.Value < 11 and pointsp2.Value < 11 do -- while there is no winner
wait(2)
pointend = false -- reset point
while pointend == false do -- while the point is still being played
if pointend == false then --player1 shot
shotp1()
c = shuttle:Clone()
c.Parent = script.Parent.Parent
wait(4)
if script.Parent.Parent.Player1.keypress.keypressedintime.Value == true then
c:Remove()
else
c:Remove()
pointsp2.Value = pointsp2.Value + 1
s = shuttlefall:Clone()
s.Parent = script.Parent.Parent
wait(2)
s:Remove()
wait(1)
pointend = true
end
end
if pointend == false then --player2 shot
shotp2()
c = shuttle:Clone()
c.Parent = script.Parent.Parent
wait(4)
if script.Parent.Parent.Player2.keypress.keypressedintime.Value == true then
c:Remove()
else
c:Remove()
pointsp1.Value = pointsp1.Value + 1
s = shuttlefall:Clone()
s.Parent = script.Parent.Parent
wait(2)
s:Remove()
wait(1)
pointend = true
end
end
end
end
end
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
20 Dec 2015 12:05 PM
The function isn't being fired
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
20 Dec 2015 12:06 PM
Whoops, my bad. -_-
X_X
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
20 Dec 2015 12:07 PM
Nvm, I was right, the function isn't being fired
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
20 Dec 2015 12:07 PM
Whoops [2]
Report Abuse
Adstract is not online. Adstract
Joined: 13 Sep 2015
Total Posts: 3342
20 Dec 2015 12:07 PM
it definitely gets to that point in the script because everything else works but it's that single if statement. it doesn't seem to recognize the fact that both string values are the same because when i set the else to true it works (but obviously i don't want this, i want it only to work when the player presses a key)
Report Abuse
cgjnm is not online. cgjnm
Joined: 22 Dec 2011
Total Posts: 2347
20 Dec 2015 12:08 PM
lol @Wolfgang
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
20 Dec 2015 12:10 PM
Is this a server script with filtering enabled???

I think it should error, but that could be why.
Report Abuse
Adstract is not online. Adstract
Joined: 13 Sep 2015
Total Posts: 3342
20 Dec 2015 12:11 PM
nope no filtering enabled, and the fact it won't error is the most annoying thing, it really should work
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
20 Dec 2015 12:12 PM
Well, stick a bunch of prints in to see what the problem is?
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
20 Dec 2015 12:13 PM
Or ensure that the values are equal to each other
Report Abuse
Adstract is not online. Adstract
Joined: 13 Sep 2015
Total Posts: 3342
20 Dec 2015 12:13 PM
well, i'll print the value of each every second and print the outcome and then print the output here to prove they are equal
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
20 Dec 2015 12:15 PM
Mkay
Report Abuse
Adstract is not online. Adstract
Joined: 13 Sep 2015
Total Posts: 3342
20 Dec 2015 12:18 PM
output:
false

false

false

false

false

false

false

false

false

false

false

false

false

false
18:26:07.572 - New connection from 127.0.0.1|51473


false
18:26:07.672 - Replication: Can't create default object of type Players
Player -1 added

false
18:26:10.092 - New connection from 127.0.0.1|63313

18:26:10.113 - Replication: Can't create default object of type Players
Player -2 added


false



false



false



false



false



false



false



false



false



false



false



false



false



false



false



false



false



false



false



false



false



false



false



false



false



false



true



true



true



true


f
false


f
false


f
false


f
false


f
false


f
false


f
false


f
false


f
false


f
false


f
false


f
false


f
false


f
false


f
false


f
false

r
f
false

r
f
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
r
false

r
f
false

r
f
false

f
f
false

f
f
false

f
f
false

f
f
false

f
f
false

f
f
false

f
f
false

f
f
false

f
f
false

f
f
false

f
f
false

f
f
false

here is shows even when they are the same it still is false
Report Abuse
Adstract is not online. Adstract
Joined: 13 Sep 2015
Total Posts: 3342
20 Dec 2015 12:20 PM
once i work this out the game will be fully playable
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
20 Dec 2015 12:21 PM
Prehaps a segement of your output next time?

Can I have a picture of your hierarchy?
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
20 Dec 2015 12:23 PM
" if script.Parent.Parent.Player1.keypress.keypressedintime.Value == true then"

That's why I would imagine, but other things with your hierarchies look dogged
Report Abuse
Adstract is not online. Adstract
Joined: 13 Sep 2015
Total Posts: 3342
20 Dec 2015 12:26 PM
here:

https://twitter.com/Legoads/status/678642748090642435?lang=en-gb
Report Abuse
Adstract is not online. Adstract
Joined: 13 Sep 2015
Total Posts: 3342
20 Dec 2015 12:27 PM
that is all the important parts which are reffered to in the script. the first part is located in workspace just to clarify. and valuechecker is just something i included to print the values as show in the output i provided previously
Report Abuse
Adstract is not online. Adstract
Joined: 13 Sep 2015
Total Posts: 3342
20 Dec 2015 12:29 PM
oh and the script with the broken if statement is the one in Player1 named 'touching'
Report Abuse
Adstract is not online. Adstract
Joined: 13 Sep 2015
Total Posts: 3342
20 Dec 2015 01:11 PM
b
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image