|
HOW THE SCRIPT WORKS: The button is based on magnitude, giving the illusion that when the Player is on the Button, they are triggering the buttons. This works for only one person. Multiple Players, however... no.
SITUATION/PROBLEM: When it was just me in the server, they were working fine. But when a friend of mine joined, I lost all access of triggering the Buttons. But the interesting part is that my friend was able to trigger the Buttons, and I was not. Once he left the server, I was given back the power of triggering the Buttons. I want the Buttons to be able to support Multiple players on the same server, triggering Buttons.
PLACE: https://www.roblox.com/games/952310433/Button-Testing (Must have a friend or someone to see this happen! I might be in the server.)
CODE:
while true do
for i, v in pairs(game.Players:GetChildren()) do
if (v.Character.Torso.Position - script.Parent.Position).magnitude <= 3.7 then
script.Parent.BrickColor = BrickColor.new("Grime")
script.Parent.Parent.Partb.CanCollide = true
script.Parent.Parent.Partb.Transparency = 0
elseif (v.Character.Torso.Position - script.Parent.Position).magnitude >= 3.7 then
script.Parent.BrickColor = BrickColor.new("Medium green")
script.Parent.Parent.Partb.CanCollide = false
script.Parent.Parent.Partb.Transparency = 1
end
end
wait()
end |
|
|
VulkarinJoin Date: 2013-03-17 Post Count: 282 |
I would make some bools to make sure one player isn't effecting another player ontop of the button...my guess is that your player was infront of his and thus he was the only one who seemingly affected the button because the script ran on him second
pressed = false
while true do
for _,v in pairs(players) do
if not pressed and tiny magnitude then pressed = true
elseif not pressed and big magnitude then return end
end
if pressed then
do stuff to brick here
else
do some other stuff to birck
end
wait(sometime)
end
|
|
|
how do i define the player with that code? |
|
|
Well, now nothing has happened:
while true do
for _,v in pairs(game.Players:GetChildren()) do
if not pressed and (v.Character.Torso.Position - script.Parent.Position).magnitude <=3.7 then pressed = true
elseif not pressed and (v.Character.Torso.Position - script.Parent.Position).magnitude >=3.7 then return end
end
if pressed then
script.Parent.BrickColor = BrickColor.new("Grime")
script.Parent.Parent.Partc.CanCollide = true
script.Parent.Parent.Partc.Transparency = 0
else
script.Parent.BrickColor = BrickColor.new("Medium green")
script.Parent.Parent.Partc.CanCollide = false
script.Parent.Parent.Partc.Transparency = 1
end
wait()
end
i'm wondering why. |
|
VulkarinJoin Date: 2013-03-17 Post Count: 282 |
ah okay my bad of you remove the return then it works
|
|
|
VulkarinJoin Date: 2013-03-17 Post Count: 282 |
why???
|
|
|
the original codel i have posted is still not fixed. |
|
VulkarinJoin Date: 2013-03-17 Post Count: 282 |
If you remove the return it works like I said earlier..
|
|
|
by return, are you talking about the 'if' statements with keypressed variable |
|
VulkarinJoin Date: 2013-03-17 Post Count: 282 |
The only return in the script
|
|
|
I just noticed the return part lol thanks. But now it only works halfway. It only gives the illusion that the player is triggering the button, but when the player steps off, the color doesn't revert back to its original color.
while true do
for _,v in pairs(game.Players:GetChildren()) do
if not pressed and (v.Character.Torso.Position - script.Parent.Position).magnitude <=3.7 then pressed = true
elseif not pressed and (v.Character.Torso.Position - script.Parent.Position).magnitude >3.7 then
pressed = false
end
end
if pressed == true then
script.Parent.BrickColor = BrickColor.new("Grime")
script.Parent.Parent.Partc.CanCollide = true
script.Parent.Parent.Partc.Transparency = 0
elseif pressed == false then
script.Parent.BrickColor = BrickColor.new("Medium green")
script.Parent.Parent.Partc.CanCollide = false
script.Parent.Parent.Partc.Transparency = 1
end
wait()
end |
|
VulkarinJoin Date: 2013-03-17 Post Count: 282 |
while true do
pressed = false
|
|
|
balcktackJoin Date: 2017-04-05 Post Count: 78 |
whats your friends name?
THIS IS A RELEVANT QUESTION! |
|