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
 

Re: Help with a script

Previous Thread :: Next Thread 
riolusniper is not online. riolusniper
Joined: 13 Jul 2009
Total Posts: 1351
10 Jun 2013 08:28 PM
When a player touches the brick, he is lifted up into the air, and to the side. It works fine, but it breaks whenever something besides the player touches the brick, like a hat or an item they're holding. Does anyone know how to fix this?



local enabled = false
debounce = true
function onTouched(part)
if not enabled then
enabled = true
script.Parent.BrickColor = BrickColor.new("Really red")
wait()
script.Parent.Smoke.Enabled = true
if part.Parent ~= nil then
local h = part.Parent:FindFirstChild("Humanoid")
if h ~= nil and debounce == true then
debounce = false
p = Instance.new("BodyPosition")
p.Parent = part.Parent.Torso
p.maxForce = Vector3.new(90000,90000,90000)
p.position = part.Parent.Torso.Position + Vector3.new(0,25,0)
wait(0.4)
p.position = part.Parent.Torso.Position + Vector3.new(0,0,-14)
wait(0.4)
p:Remove()
script.Parent.Smoke.Enabled = false
script.Parent.BrickColor = BrickColor.new("Black")
enabled = false
debounce = true
end
end
end
end
script.Parent.Touched:connect(onTouched)
Report Abuse
SparkyMac is not online. SparkyMac
Joined: 27 Jul 2012
Total Posts: 1863
10 Jun 2013 08:33 PM
I think its because the script only knows about humanoid. If it find something else then a humanoid it will bug out. I think you should make a script that makes it recognize stuff.
Report Abuse
riolusniper is not online. riolusniper
Joined: 13 Jul 2009
Total Posts: 1351
10 Jun 2013 08:34 PM
What would I use to make it recognize more than just humanoid?
Report Abuse
SparkyMac is not online. SparkyMac
Joined: 27 Jul 2012
Total Posts: 1863
10 Jun 2013 08:35 PM
I think it is because the script doesn't know anything else but the Humanoid.I think you need to make a script that will make the brick recognize more stuff.
Report Abuse
SparkyMac is not online. SparkyMac
Joined: 27 Jul 2012
Total Posts: 1863
10 Jun 2013 08:36 PM
You could make a scrip.t that clears all hats.So you just wont have the problem, Or you could make a script that names all hats one certain thing or everything thats not a humanoid one thing so then it will know it.
Report Abuse
2unknown2 is not online. 2unknown2
Joined: 30 Oct 2011
Total Posts: 9351
10 Jun 2013 08:36 PM
Capitalize position.

We are anonymous. We do not forgive. We do not forget.
Report Abuse
riolusniper is not online. riolusniper
Joined: 13 Jul 2009
Total Posts: 1351
10 Jun 2013 08:37 PM
It's mostly guns that are the problem, when someone jumps down from the floor above it, and the gun touches the brick.
Report Abuse
riolusniper is not online. riolusniper
Joined: 13 Jul 2009
Total Posts: 1351
10 Jun 2013 08:41 PM
@2unknown2, How would that fix the problem...
Report Abuse
riolusniper is not online. riolusniper
Joined: 13 Jul 2009
Total Posts: 1351
10 Jun 2013 08:59 PM
Still haven't fixed it :\
Report Abuse
riolusniper is not online. riolusniper
Joined: 13 Jul 2009
Total Posts: 1351
10 Jun 2013 09:55 PM
bump
Report Abuse
Frostglacier is not online. Frostglacier
Joined: 28 Oct 2010
Total Posts: 4177
10 Jun 2013 10:25 PM
local enabled = false
debounce = true

function onTouched(part)
if enabled == false then
enabled = true
local h = part.Parent:FindFirstChild("Humanoid")
if h ~= nil and debounce == true then
script.Parent.BrickColor = BrickColor.new("Really red")
wait()
script.Parent.Smoke.Enabled = true
debounce = false
p = Instance.new("BodyPosition")
p.Parent = part.Parent.Torso
p.maxForce = Vector3.new(90000,90000,90000)
p.position = part.Parent.Torso.Position + Vector3.new(0,25,0)
wait(0.4)
p.position = part.Parent.Torso.Position + Vector3.new(0,0,-14)
wait(0.4)
p:Remove()
script.Parent.Smoke.Enabled = false
script.Parent.BrickColor = BrickColor.new("Black")
enabled = false
debounce = true
end
end
end

script.Parent.Touched:connect(onTouched)
Report Abuse
riolusniper is not online. riolusniper
Joined: 13 Jul 2009
Total Posts: 1351
12 Jun 2013 04:57 PM
That made the brick not activate when a hat or gun touches it, but it still breaks it.
Report Abuse
Boomboy45 is not online. Boomboy45
Joined: 12 Oct 2008
Total Posts: 3720
12 Jun 2013 05:20 PM
You need to spell things EXACTLY right and that includes capitalizing all of the correct stuff, et cetera.

Run the script and tell us what the Output says.

-From the desk of the Premier of Trashcanistan
Report Abuse
riolusniper is not online. riolusniper
Joined: 13 Jul 2009
Total Posts: 1351
12 Jun 2013 05:29 PM
Here's the output:


script.Parent.Touched:connect(onTouched)
16:26:18.930 - local enabled = false
debounce = true

function onTouched(p:29: attempt to index global 'script' (a nil value)
16:26:18.934 - Script "local enabled = false
debounce = true

function onTouched(p", Line 29
16:26:18.935 - stack end
Report Abuse
riolusniper is not online. riolusniper
Joined: 13 Jul 2009
Total Posts: 1351
12 Jun 2013 05:36 PM
There is nothing in the output when I touch the gun to the part (which breaks it). However, I found that once the script is broken, it is not disabled. Once I disable it, and enable it again, it works.
Report Abuse
Boomboy45 is not online. Boomboy45
Joined: 12 Oct 2008
Total Posts: 3720
12 Jun 2013 05:51 PM
I'm not at this level of scripting yet. Sorry mate.

-From the desk of the Premier of Trashcanistan
Report Abuse
riolusniper is not online. riolusniper
Joined: 13 Jul 2009
Total Posts: 1351
12 Jun 2013 06:09 PM
That's okay.
Report Abuse
iIikeyou is not online. iIikeyou
Joined: 07 Mar 2012
Total Posts: 1659
12 Jun 2013 06:18 PM
local d={}
script.Parent.Touched:connect(function(c)
c=game:GetService'Players':GetPlayerFromCharacter(c.Parent)or game:GetService'Players':GetPlayerFromCharacter(c.Parent.Parent)
if c and not d[c.Name]then
script.Parent:FindFirstChild'Smoke'.Enabled=true
script.Parent.BrickColor=BrickColor.new'Really red'
d[c.Name]=true
c=c.Character
local b=Instance.new('BodyPosition',c:FindFirstChild'Torso')
b.maxForce=Vector3.new(900000,900000,900000)
b.position=c:FindFirstChild'Torso'.Position+Vector3.new(0,25,0)
wait(.4)
b.position=c:FindFirstChild'Torso'.Position-Vector3.new(0,0,14)
wait(.4)
b:Destroy()
script.Parent:FindFirstChild'Smoke'.Enabled=false
script.Parent.BrickColor=BrickColor.new'Black'
d[c.Name]=false
end
end)
Report Abuse
riolusniper is not online. riolusniper
Joined: 13 Jul 2009
Total Posts: 1351
12 Jun 2013 06:32 PM
That didn't work.
Report Abuse
Nagrath99 is not online. Nagrath99
Joined: 26 Mar 2011
Total Posts: 1537
12 Jun 2013 06:33 PM
This scripting style is horrible.
Report Abuse
riolusniper is not online. riolusniper
Joined: 13 Jul 2009
Total Posts: 1351
12 Jun 2013 06:48 PM
Then why don't you try to help instead of just saying it's horrible?
Report Abuse
riolusniper is not online. riolusniper
Joined: 13 Jul 2009
Total Posts: 1351
12 Jun 2013 07:50 PM
Still haven't fixed it.
Report Abuse
riolusniper is not online. riolusniper
Joined: 13 Jul 2009
Total Posts: 1351
12 Jun 2013 08:27 PM
I've been working on it for three hours now... Would it work if I added another script, with the same parent as the main script, and did something like:


if script.Parent.Smoke.Enabled == true then --Smoke is turned on after the part is touched anyway.

wait(1.3) --It takes almost 1.3 seconds to complete the main script.

script.Parent.Mover.Disabled = true --Mover is the name of the main script
wait()
script.Parent.Mover.Disabled = false --Like I said it works if I disable and re-enable it again.

end


I've tried to use these exact lines, but it didn't work. I'm a beginner scripter, so I'm assuming I may have made a small mistake.

At one time I made another script that disables it and re-enables it every 5 seconds, but if the main script was running while it was being disabled, it broke.
Report Abuse
riolusniper is not online. riolusniper
Joined: 13 Jul 2009
Total Posts: 1351
12 Jun 2013 11:07 PM
Bump
Report Abuse
riolusniper is not online. riolusniper
Joined: 13 Jul 2009
Total Posts: 1351
13 Jun 2013 04:18 PM
Bump
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