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: How do I make a script that only affects yourself?

Previous Thread :: Next Thread 
pieterpasta is not online. pieterpasta
Joined: 02 Feb 2014
Total Posts: 12
19 Apr 2017 02:01 PM
I'm new to scripting, and I made my first "big" script.
When you touch a part in game, a random GUI will show up on the screen.
I tried to make it so that only the player that touches the brick gets the GUI shown.

I made a LocalScript, and put it in StarterPlayer>StarterCharacterScripts.

I did the GUI in StarterGui, and made .Enabled = false.

When you touch the brick, I made it so that when the player touches it, the gui gets .Enabled = true.

game.Players.LocalPlayer.PlayerGui.picture.Enabled = true

Which works, but not only for the Player that touches the brick, but for all players in the whole server.

I've tried googling this, but couldn't find anything, help?
Report Abuse
LaeMVP is online. LaeMVP
Joined: 24 Jun 2013
Total Posts: 4416
19 Apr 2017 02:02 PM
Show us the script.
Report Abuse
pieterpasta is not online. pieterpasta
Joined: 02 Feb 2014
Total Posts: 12
19 Apr 2017 02:06 PM
local SCPTouch = false

local picture = game.Players.LocalPlayer.PlayerGui.Picture
local picture1 = game.Players.LocalPlayer.PlayerGui.Picture1
local picture2 = game.Players.LocalPlayer.PlayerGui.Picture2
local picture3 = game.Players.LocalPlayer.PlayerGui.Picture3
local picture4 = game.Players.LocalPlayer.PlayerGui.Picture4

local music = game.Players.LocalPlayer.PlayerGui.Jumpscare


picture.Enabled = false
picture1.Enabled = false
picture2.Enabled = false
picture3.Enabled = false
picture4.Enabled = false



game.Workspace.SCP895.Sensor.Touched:connect(function(part)

print("Touched!")
if not SCPTouch then
SCPTouch = true

while true do
wait(3)

local num = math.random(1,4)
print("Neat images")

if num == 1 then
print(1)
wait(5)
picture.Enabled = true
music.JumpscareSound.Playing = true
wait(0.4)
picture.Enabled = false
end


if num == 2 then
print(2)
wait(5)
picture1.Enabled = true
music.JumpscareSound.Playing = true
wait(0.4)
picture1.Enabled = false
end

if num == 3 then
print(3)
wait(5)
picture2.Enabled = true
music.JumpscareSound.Playing = true
wait(0.4)
picture2.Enabled = false
end

if num == 4 then
print(4)
wait(5)
picture3.Enabled = true
music.JumpscareSound.Playing = true
wait(0.4)
picture3.Enabled = false

end

if num == 5 then
print(5)
wait(5)
picture4.Enabled = true
music.JumpscareSound.Playing = true
wait(0.4)
picture4.Enabled = false
end

end

wait(100000)
SCPTouch = false
end

end)







I understand that there is a lot of flaws in this script, but I'm very new to scripting.
Report Abuse
Atavis is not online. Atavis
Joined: 10 Apr 2012
Total Posts: 1463
19 Apr 2017 02:09 PM
you can use print() to output things to the console window. To see if the script made it as far as the line the print was on. It's like primitive debugging compared to most IDEs of various programming languages irrelevant to this topic. You can use print() to print values print(x) or print a ####################### you feel like print("This is a message!!!") I use this all the time to logically step through all my code to make sure it's doing exactly what I intend it to. #code --This validates my comment.
Report Abuse
Atavis is not online. Atavis
Joined: 10 Apr 2012
Total Posts: 1463
19 Apr 2017 02:10 PM
ROBLOX then proceeds to ---- me over because I called their debugging method primitive.


#code --This validates my comment.
Report Abuse
pieterpasta is not online. pieterpasta
Joined: 02 Feb 2014
Total Posts: 12
19 Apr 2017 02:14 PM
I use print to check errors, yes, and there weren't any so far. However, when I test it out with multiple Players, any Player that touches the brick, makes the whole server see the imagery. I want only the Player that touches the brick to see the imagery, not the whole server.
Report Abuse
LaeMVP is online. LaeMVP
Joined: 24 Jun 2013
Total Posts: 4416
19 Apr 2017 02:14 PM
That looks like a big bowl of pasta.
Report Abuse
Atavis is not online. Atavis
Joined: 10 Apr 2012
Total Posts: 1463
19 Apr 2017 02:31 PM
Is FE true? This will only work under FE I think. Honestly I couldn't be bothered to read the script fully but I didn't see any syntax errors I think so if FE is on you should be good.


#code --This validates my comment.
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