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 » Scripting Helpers
Home Search
 

Script eror

Previous Thread :: Next Thread 
edc900 is not online. edc900
Joined: 25 Apr 2010
Total Posts: 170
19 Dec 2012 05:25 PM
Script: p = script.Parent
function onClick(click)
p.Parent.Door.CanColide = false and p.Parent.Door.Transparency = 1
wait(3)
p.Parent.Door.CanColide = true and p.Parent.Transparency = 0
end
p.ClickDetector:MouseClicked:connect(onClicked)

Eror: Script:3: unexpected symbol near '='

What does it mean and how can i fix it?
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
19 Dec 2012 05:29 PM
p = script.Parent

function onClick(click)
p.Parent.Door.CanColide = false
p.Parent.Door.Transparency = 1
wait(3)
p.Parent.Door.CanColide = true
p.Parent.Transparency = 0
end

p.ClickDetector:MouseClicked:connect(onClicked)


This should work. n_n
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
19 Dec 2012 05:29 PM
Script:
partSelect = script.Parent

partSelect.ClickDetector.MouseClick:connect(function()
partSelect.Parent.Door.CanColide = false
partSelect.Parent.Door.Transparency = 1
wait(3)
partSelect.Parent.Door.CanColide = true
partSelect.Parent.Transparency = 0
end)
Report Abuse
Spectrumw is not online. Spectrumw
Joined: 04 Aug 2009
Total Posts: 13510
19 Dec 2012 05:30 PM
Oh wait, I didn't notice you missed a 'Door' when changing back the Transparency.

p = script.Parent

function onClick(click)
p.Parent.Door.CanColide = false
p.Parent.Door.Transparency = 1
wait(3)
p.Parent.Door.CanColide = true
p.Parent.Door.Transparency = 0
end

p.ClickDetector:MouseClicked:connect(onClicked)
Report Abuse
edc900 is not online. edc900
Joined: 25 Apr 2010
Total Posts: 170
19 Dec 2012 05:32 PM
Ohhhhhh. I'll try it, thanks.
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
19 Dec 2012 05:32 PM
I didn't see that either. I would also like to add anonymous functions are better than connection line ones. Also, declaring variables with useful names with definition will help in a larger script, so start doing it with smaller ones.

- thedestroyer115
Report Abuse
NewbControl114 is not online. NewbControl114
Joined: 09 May 2009
Total Posts: 10303
19 Dec 2012 05:40 PM
Is it just me or did nobody notice the fact that 'CanColide' is not a property? Just asking?
Here is a fixed script. There were a few errors I saw. (Please tell me if I'm wrong, sorta new to Lua).

p = script.Parent

function onClick(click)
p.Parent.Door.CanCollide = false --CanCollide is a property, not CanColide.
p.Parent.Door.Transparency = 1
wait(3)
p.Parent.Door.CanCollide = true
p.Parent.Transparency = 0
end

p.ClickDetector.MouseClicked:connect(onClick) -- ** see below

** here on your function calling you put "p.ClickDetector:MouseClicked:connect".

This will error the script as it will try to find 'MouseClicked' as an event or function. Furthermore, you put 'OnClick' as your function in the ( ), but is not the name of the function that you put.

Hope this helps.

MouseClicked is a hidden property of P.ClickDetector'.
Report Abuse
edc900 is not online. edc900
Joined: 25 Apr 2010
Total Posts: 170
19 Dec 2012 05:41 PM
When I test it, it says: attempt to call a nil value Disconnected event because of exception
Report Abuse
NewbControl114 is not online. NewbControl114
Joined: 09 May 2009
Total Posts: 10303
19 Dec 2012 05:41 PM
Also, change that "p.Parent.Transparency = 0" to "p.Parent.Door.Transparency = 0". That is not an error that will show up but your door will stay transparent forever.
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
19 Dec 2012 05:46 PM
Finally fixed script:


partSelect = script.Parent

partSelect.ClickDetector.MouseClick:connect(function()
partSelect.Parent.Door.CanCollide = false
partSelect.Parent.Door.Transparency = 1; wait(3)
partSelect.Parent.Door.CanCollide = true
partSelect.Parent.Door.Transparency = 0
end)


- thedestroyer115
Report Abuse
edc900 is not online. edc900
Joined: 25 Apr 2010
Total Posts: 170
19 Dec 2012 05:50 PM
No errors, but door won't open...
Report Abuse
NewbControl114 is not online. NewbControl114
Joined: 09 May 2009
Total Posts: 10303
19 Dec 2012 05:52 PM
Can you give us an idea of what your explorer tree looks like?

This is what I am thinking it is.


Workspace
-Model
--Script
--Door

Is that what it looks like?
Report Abuse
edc900 is not online. edc900
Joined: 25 Apr 2010
Total Posts: 170
19 Dec 2012 06:16 PM
workspace-model-door, part-Clickdetecor, script
Report Abuse
edc900 is not online. edc900
Joined: 25 Apr 2010
Total Posts: 170
19 Dec 2012 06:21 PM
-workspace
--modle
door
part-script+clickdetector
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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