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: I need help with a script that's simple for others.

Previous Thread :: Next Thread 
DarkAndLight64 is not online. DarkAndLight64
Joined: 06 Sep 2013
Total Posts: 25
07 Jun 2015 11:28 PM
I'm a new scripter trying to make scripts. For some reason there is a squiggly line under the first equal sign in this script:

function
if
PlayerId = ("48169798")
then Part.Door.CanColide = false
wait(1)
then Part.Door.CanColide = true


end
end


Could you people help out?
Report Abuse
DarkAndLight64 is not online. DarkAndLight64
Joined: 06 Sep 2013
Total Posts: 25
07 Jun 2015 11:32 PM
oh squiggly line under the if, if i take out the if there's a squiggly line under the first equal sign where it says PlayerId = ("48169798")
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
07 Jun 2015 11:36 PM
However, make sure that PlayerId and Part are defined somewhere above this all..

The reason it was squiggly was because you need a double equals sign when comparing.

local magic = function()
if PlayerId == 48169798 then
Part.Door.CanColide = false
wait(1)
then Part.Door.CanColide = true
end
end
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
07 Jun 2015 11:37 PM
My bad, I forgot to take out a rogue _then_.

local magic = function()
if PlayerId == 48169798 then
Part.Door.CanColide = false
wait(1)
Part.Door.CanColide = true
end
end
Report Abuse
voItages is not online. voItages
Joined: 02 Nov 2013
Total Posts: 677
07 Jun 2015 11:39 PM
And CanCollide is spelled wrong



=volty=
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
07 Jun 2015 11:41 PM
Problems:
1. the function needs a name

function WhateverYouwant()
if
PlayerId = ("48169798")
then Part.Door.CanColide = false
wait(1)
then Part.Door.CanColide = true


end
end

2.When ur checkiong, u need two =='s

function WhateverYouwant()
if
PlayerId == ("48169798") then
Part.Door.CanColide = false
wait(1)
Part.Door.CanColide = true


end
end

3. You forgot to say waht part is, all the computer knows is workspace and the script.Parent, so u need to define part. Lets add the argument of who touched it, we'll need it later.

local Part = game.Workspace.Part
function WhateverYouwant(hit)
if PlayerId == ("48169798") then
Part.Door.CanColide = false
wait(1)
Part.Door.CanColide = true

end
end

4. You never called the function, that just means u write it so it does it. Lets say we call the function when someone touches the door, then we use the touched function, which we connect it to.

local Part = game.Workspace.Part
function WhateverYouwant(hit)
if PlayerId == ("48169798") then
Part.Door.CanColide = false
wait(1)
Part.Door.CanColide = true

end
end

Part.Door.Touched:connect(WhateverYouwant)

5.Lets say who the person is, so we can find their id to check

local Part = game.Workspace.Part
function WhateverYouwant(hit)
local PLAYER = game.Players:GetPlayerFromCharacter(hit.Parent)
if PlayerId == ("48169798") then
Part.Door.CanColide = false
wait(1)
Part.Door.CanColide = true

end
end

Part.Door.Touched:connect(WhateverYouwant)

6. What if a person doesent touch it and a brick does? then it'll make an error, so lets add a pcall(restarts if it errors)

local Part = game.Workspace.Part
function WhateverYouwant(hit)
pcall(function()
local PLAYER = game.Players:GetPlayerFromCharacter(hit.Parent)
if PlayerId == ("48169798") then
Part.Door.CanColide = false
wait(1)
Part.Door.CanColide = true

end
end)
end

Part.Door.Touched:connect(WhateverYouwant)

7. Now that we have the player, all we need is the Id to check if he can open the door. So lets do that by adding a defined variable called PlayerId, as you said.

local Part = game.Workspace.Part
function WhateverYouwant(hit)
pcall(function()
local PLAYER = game.Players:GetPlayerFromCharacter(hit.Parent)
PlayerId = PLAYER.userID-- this takes the Id!
if PlayerId == ("48169798") then
Part.Door.CanColide = false
wait(1)
Part.Door.CanColide = true

end
end)
end

Part.Door.Touched:connect(WhateverYouwant)


Alright, put this in a normal script in workspace.


local Part = game.Workspace.Part
function WhateverYouwant(hit)
pcall(function()
local PLAYER = game.Players:GetPlayerFromCharacter(hit.Parent)
PlayerId = PLAYER.userID-- this takes the Id!
if PlayerId == ("48169798") then
Part.Door.CanColide = false
wait(1)
Part.Door.CanColide = true

end
end)
end

Part.Door.Touched:connect(WhateverYouwant)




Make sure there is a Part in the workspace named "Part" and a door inside it.
Hope it works! Report any errors if it doesent
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
07 Jun 2015 11:43 PM
sry, looks like can collide is spelled wrong, put this script in

local Part = game.Workspace.Part
function WhateverYouwant(hit)
pcall(function()
local PLAYER = game.Players:GetPlayerFromCharacter(hit.Parent)
PlayerId = PLAYER.userID-- this takes the Id!
if PlayerId == ("48169798") then
Part.Door.CanCollide = false
wait(1)
Part.Door.CanCollide = true

end
end)
end

Part.Door.Touched:connect(WhateverYouwant)
Report Abuse
voItages is not online. voItages
Joined: 02 Nov 2013
Total Posts: 677
07 Jun 2015 11:43 PM
CanCollide is still spelled wrong in the script.



=volty=
Report Abuse
voItages is not online. voItages
Joined: 02 Nov 2013
Total Posts: 677
07 Jun 2015 11:44 PM
got ninja'd and also it's userid not userID



=volty=
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
07 Jun 2015 11:46 PM
really? I got told otherwise.
Report Abuse
voItages is not online. voItages
Joined: 02 Nov 2013
Total Posts: 677
07 Jun 2015 11:48 PM
Correction: userId



=volty=
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
08 Jun 2015 12:02 AM
local Part = game.Workspace.Part
function WhateverYouwant(hit)
pcall(function()
local PLAYER = game.Players:GetPlayerFromCharacter(hit.Parent)
PlayerId = PLAYER.userId-- this takes the Id!
if PlayerId == ("48169798") then
Part.Door.CanCollide = false
wait(1)
Part.Door.CanCollide = true

end
end)
end

Part.Door.Touched:connect(WhateverYouwant)

this will work. Try it.
Report Abuse
DarkAndLight64 is not online. DarkAndLight64
Joined: 06 Sep 2013
Total Posts: 25
10 Jun 2015 10:23 AM
Jesus Christ...
Report Abuse
ApocSurrvivalist is not online. ApocSurrvivalist
Joined: 22 Apr 2013
Total Posts: 5840
10 Jun 2015 10:26 AM
Lol he just replys jesus christ

LeBlanc true assassin http://www.roblox.com/Trade/TradeWindow.aspx?TradePartnerID=41451881
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