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: C4 script Issues

Previous Thread :: Next Thread 
THEMENDEZKID is not online. THEMENDEZKID
Joined: 18 Aug 2011
Total Posts: 2401
10 May 2014 08:50 PM
The issues are self explanatory on the script if you are experienced.

Before you read on, here are some clues I found inside the console if it proves useful--

18:47:31.872 - Players.Player1.Backpack.C4.Script:19: attempt to index global 'C4' (a nil value)


Script;

function onMouseClick1()
Instance.new('Part', Workspace)
Instance.new('Decal', Workspace.Part)
Instance.new('Decal', Workspace.Part)
Workspace.Part.Position = Workspace.Player1.Head.Position
Workspace.Part.Size = Vector3.new(2, 1.2, 2)
Workspace.Part.BottomSurface = "SmoothNoOutlines"
Workspace.Part.TopSurface = "SmoothNoOutlines"
Workspace.Part.Decal.Texture = "http://www.roblox.com/asset/?id=149185724"
Workspace.Part.Decal.Name = "d1"
Workspace.Part.Decal.Name = "d2"
Workspace.Part.d1.Texture = "http://www.roblox.com/asset/?id=149185724"
Workspace.Part.d2.Texture = "http://www.roblox.com/asset/?id=149185724"
Workspace.Part.d1.Face = "Bottom"
Workspace.Part.d2.Face = "Top"
Workspace.Part.BrickColor = BrickColor.Yellow()
C4:Destroy()
end

C4.MouseClick1:connect(onMouseClick1)
Report Abuse
VirtualPrince is not online. VirtualPrince
Joined: 17 Oct 2013
Total Posts: 7386
10 May 2014 08:51 PM
The variable for "C4" is not correct
Report Abuse
THEMENDEZKID is not online. THEMENDEZKID
Joined: 18 Aug 2011
Total Posts: 2401
10 May 2014 09:17 PM
bump
Report Abuse
VirtualPrince is not online. VirtualPrince
Joined: 17 Oct 2013
Total Posts: 7386
10 May 2014 09:21 PM
Oops,
"C4.MouseButton1Click:connect(onClick)"
Report Abuse
tery215 is not online. tery215
Joined: 19 Aug 2009
Total Posts: 3879
10 May 2014 09:31 PM
use :Remove()

also, that's an unreliable system you got there
Report Abuse
THEMENDEZKID is not online. THEMENDEZKID
Joined: 18 Aug 2011
Total Posts: 2401
10 May 2014 10:14 PM
@tery215
I know. It's just an experiment. I'm still a noob at Lua but I mostly enjoy it.
Report Abuse
THEMENDEZKID is not online. THEMENDEZKID
Joined: 18 Aug 2011
Total Posts: 2401
10 May 2014 10:44 PM
bump
Report Abuse
THEMENDEZKID is not online. THEMENDEZKID
Joined: 18 Aug 2011
Total Posts: 2401
10 May 2014 10:44 PM
Would someone then kindly rewrite the script for me? It's getting confusing for me now...
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
10 May 2014 10:45 PM
You never told the script what "C4" is
Report Abuse
THEMENDEZKID is not online. THEMENDEZKID
Joined: 18 Aug 2011
Total Posts: 2401
10 May 2014 10:52 PM
@128GB

C4 Is the tool inside your character. I did this so it would limit to only one C4.
Report Abuse
wazap is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
10 May 2014 10:53 PM
You never defined it tho
Report Abuse
THEMENDEZKID is not online. THEMENDEZKID
Joined: 18 Aug 2011
Total Posts: 2401
10 May 2014 10:58 PM
@wazap

I recently made changes to my script--

Tool = Workspace:findFirstChild("Model") --finds the model of the player
if Workspace.Model ~= true then

function onClick()
Instance.new('Part', Workspace)
Instance.new('Decal', Workspace.Part)
Instance.new('Decal', Workspace.Part)
Workspace.Part.Position = Workspace.Player1.Head.Position
Workspace.Part.Size = Vector3.new(2, 1.2, 2)
Workspace.Part.BottomSurface = "SmoothNoOutlines"
Workspace.Part.TopSurface = "SmoothNoOutlines"
Workspace.Part.Decal.Texture = "http://www.roblox.com/asset/?id=149185724"
Workspace.Part.Decal.Name = "d1"
Workspace.Part.Decal.Name = "d2"
Workspace.Part.d1.Texture = "http://www.roblox.com/asset/?id=149185724"
Workspace.Part.d2.Texture = "http://www.roblox.com/asset/?id=149185724"
Workspace.Part.d1.Face = "Bottom"
Workspace.Part.d2.Face = "Top"
Workspace.Part.BrickColor = BrickColor.Yellow()
Script.Parent.Parent.C4:Remove()
end
end

Tool.C4.MouseButton1Click:connect(onClick)
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
10 May 2014 10:59 PM
"Tool = Workspace:findFirstChild("Model") --finds the model of the player"

No, it finds a object in the workspace named Model. Not the character.
Report Abuse
THEMENDEZKID is not online. THEMENDEZKID
Joined: 18 Aug 2011
Total Posts: 2401
10 May 2014 11:05 PM
@128GB

Well all I can think of is a Touched event that can gain access to the user...

function onTouched(hit)
print(hit.Parent)
end

Workspace.Part.Touched:connect(onTouched)

But it wouldn't make sense...
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
10 May 2014 11:06 PM
script.Parent -- this is the tool
script.Parent.Parent -- this is the character
Report Abuse
THEMENDEZKID is not online. THEMENDEZKID
Joined: 18 Aug 2011
Total Posts: 2401
10 May 2014 11:06 PM
I also want to know how to make the "MouseButton" a bindable function to execute the script.

Report Abuse
THEMENDEZKID is not online. THEMENDEZKID
Joined: 18 Aug 2011
Total Posts: 2401
10 May 2014 11:09 PM
I tried that, which resulted in this--

21:08:11.437 - Players.Player1.Backpack.C4.Script:1: attempt to index global 'Script' (a nil value)
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
10 May 2014 11:10 PM
script ~= Script
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
10 May 2014 11:17 PM
C4 = script.Parent

function onMouseClick1()
p = Instance.new('Part', Workspace)
d1 = Instance.new('Decal', Workspace.Part)
d2 = Instance.new('Decal', Workspace.Part)
p.Position = Char.Head.Position
p.Size = Vector3.new(2, 1.2, 2)
p.BottomSurface = "SmoothNoOutlines"
p.TopSurface = "SmoothNoOutlines"
d1.Texture = "http://www.roblox.com/asset/?id=149185724"
d1.Name = "d1"
d2.Name = "d2"
d1.Texture = "http://www.roblox.com/asset/?id=149185724"
d2.Texture = "http://www.roblox.com/asset/?id=149185724"
d1.Face = "Bottom"
d2.Face = "Top"
p.BrickColor = BrickColor.Yellow()
C4:Destroy()
end

C4.Equipped:connect(function(Mouse)
Char = C4.Parent
Mouse.Button1Down:connect(onMouseClick1)
end)

Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
10 May 2014 11:22 PM
C4 = script.Parent

function onMouseClick1()
p = Instance.new('Part', Workspace)
d1 = Instance.new('Decal', p)
d2 = Instance.new('Decal', p)
p.Position = Char.Head.Position
p.Size = Vector3.new(2, 1.2, 2)
p.BottomSurface = "SmoothNoOutlines"
p.TopSurface = "SmoothNoOutlines"
d1.Texture = "http://www.roblox.com/asset/?id=149185724"
d1.Name = "d1"
d2.Name = "d2"
d1.Texture = "http://www.roblox.com/asset/?id=149185724"
d2.Texture = "http://www.roblox.com/asset/?id=149185724"
d1.Face = "Bottom"
d2.Face = "Top"
p.BrickColor = BrickColor.Yellow()
C4:Destroy()
end

C4.Equipped:connect(function(Mouse)
Char = C4.Parent
Mouse.Button1Down:connect(onMouseClick1)
end)
Report Abuse
THEMENDEZKID is not online. THEMENDEZKID
Joined: 18 Aug 2011
Total Posts: 2401
11 May 2014 10:18 PM
Thanks for the working script islandmaker2012.
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