Dwarlon
|
  |
| Joined: 18 Jul 2013 |
| Total Posts: 4604 |
|
|
| 22 Nov 2013 09:24 PM |
I am making a loosely-based Zelda game and so far I have made a health potion, but I haven't scripted it yet. I need a script that onclick will restore 250 health and delete itself from the players inventory (I would prefer if you altered a Bloxi-Cola). Another thing I need is a script where if the player has 2 of 1 item, it deletes one of the dual items. I think it would be easier to tell you what certain items I plan to have, (You can use LinkedSword in the script, I can just alter it)
I also need a thing where if Brick "a" touches Brick "b", then a door opens. I have the door opening, it is a real basic script, but I do not know how to do a script with brick collision.
Door opening script:
door=script.Parent door.Transparency = 0 wait(1) door.Transparency = .1 wait(1) door.Transparency = .2 wait(1) door.Transparency = .3 wait(1) door.Transparency = .4 wait(1) door.Transparency = .5 wait(1) door.Transparency = .6 wait(1) door.Transparency = .7 wait(1) door.Transparency = .8 wait(1) door.Transparency = .9 wait(1) door.Transparency = 1 door.CanCollide = False
And one more thing, I need an NPC that does not attack you until you touch brick "(Brickname)", and that same NPC will regen if you step outside of a door. (I will put a tile outside of each door for that)
And lastly, I need a key that, once again, deletes itself after one use and makes a door use the open script. (Hold it in your hand and click on the door)
Oh, and two questions:
1.) If I put a CanCollide = False brick thaat is locked, can bricks pass through? Is it possible to make a brick that Players walk through but not bricks?
2.) Can I make a tool with a handle that is a model/group? Does it have to be a mesh? Do I need a handle?
Thank you in advance.
|
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 22 Nov 2013 10:08 PM |
We arent going to create the script for you, but we will help out with existing scripts. So I'm tots ignoring the first request.
But Touched event works like this
BrickName.Touched:connect(function(ObjectThatTouchedBrickName) --Code here end)
And the key is simple. function onActivated() --code for when you click the object Tool:Destroy() end)
Question 1 answer: yes. Anything can pass through a CanCollide = false brick. And yes you can, it involves BrickName.Touched
script.Parent.Touched:connect(function(part) if game.Players:GetPlayerFromCharacter(part.Parent) then part.Parent:MoveTo(newLocation) end end)
Question 2 The handle must be a part. No it cannot be a model or a mesh, however you can weld it using some scripts (I recommend Farvei's instaweld script), and you can place meshes inside other bricks. |
|
|
| Report Abuse |
|
|
Dwarlon
|
  |
| Joined: 18 Jul 2013 |
| Total Posts: 4604 |
|
|
| 22 Nov 2013 10:13 PM |
| Thank you, but I am having trouble with the handle. Is it possible to weld a model onto the handle, then make the real handle invisible? Would the animation still work? |
|
|
| Report Abuse |
|
|
Dwarlon
|
  |
| Joined: 18 Jul 2013 |
| Total Posts: 4604 |
|
|
| 22 Nov 2013 10:14 PM |
| And, how would I make a script where the tool would not set the health, but add 250? If I know how to add with LUA I can finish the tool. |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 22 Nov 2013 10:17 PM |
I havent tried keeping a model in a tool, but if you want to use Farvei's, you should put the model in the tool then ungroup it.
Assuming the Tool is in Character script.Parent.Parent.Health = math.min(script.Parent.Parent.MaxHealth,script.Parent.Parent.Health +250) |
|
|
| Report Abuse |
|
|
Dwarlon
|
  |
| Joined: 18 Jul 2013 |
| Total Posts: 4604 |
|
|
| 22 Nov 2013 10:33 PM |
Ok, sorry, I still don't understand the brick-touches-brick script.
Assuming you have played Ocarina of Time, (Or any other Zelda game), Link must push blocks into certain spots in the dungeon to activate doors. I put the script you gave me into the spot on the ground, (named "xspota"), and for the "Type brickname here", I wrote in "ibricka". How do I make this trigger the door's opening? |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 22 Nov 2013 10:38 PM |
You need to use the Entire Name. So game.Workspace.ibricka instead of ibricka Just copy and paste the code you originally had into the place where it says --code |
|
|
| Report Abuse |
|
|
Dwarlon
|
  |
| Joined: 18 Jul 2013 |
| Total Posts: 4604 |
|
|
| 22 Nov 2013 10:45 PM |
Ok, I must admit I am really bad at scripting, so here is what I have:
game.Workspace.door = door
BrickName.Touched:connect(function(game.Workspace.ibricka)
door.Transparency = 0 wait(1) door.Transparency = .1 wait(1) door.Transparency = .2 wait(1) door.Transparency = .3 wait(1) door.Transparency = .4 wait(1) door.Transparency = .5 wait(1) door.Transparency = .6 wait(1) door.Transparency = .7 wait(1) door.Transparency = .8 wait(1) door.Transparency = .9 wait(1) door.Transparency = 1 door.CanCollide = False
end
It gives me a redline under BrickName.Touched:connect(function(game.Workspace.ibricka) And when I scroll over it, it says:
')' expected near '.' |
|
|
| Report Abuse |
|
|
MettaurSp
|
  |
| Joined: 20 Mar 2010 |
| Total Posts: 3179 |
|
|
| 22 Nov 2013 10:51 PM |
Try using a for loop to clean up your code: for var_name = start_value,end_value,scale do --code here end |
|
|
| Report Abuse |
|
|
Dwarlon
|
  |
| Joined: 18 Jul 2013 |
| Total Posts: 4604 |
|
|
| 22 Nov 2013 10:54 PM |
| Well.... Sorry, can you explain what that does exactly? : / Sorry, but thaks for being patient. |
|
|
| Report Abuse |
|
|
domorox17
|
  |
| Joined: 06 Mar 2012 |
| Total Posts: 1710 |
|
|
| 22 Nov 2013 10:56 PM |
| what is dis LUA? its Lua... |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 22 Nov 2013 10:57 PM |
game.Workspace.door = door
game.Workspace.ibricka.Touched:connect(function(part) for k = 0, 10, 1 do door.Transparency = k*.1 wait(1) door.CanCollide = False end end) |
|
|
| Report Abuse |
|
|
|
| 22 Nov 2013 10:58 PM |
This is a loop. Variable is equal to Start. Every time the loop is ran. The increment is added to the Varaible. The loop continues until the Variable is the same as the End value.
for Variable=Start,End,Increment do --Stuff end ------------------------ So using the bellow code: --- for var=1,10,1 do print(var) end --- this would print 1,2,3,4,5,6,7,8,9,10 ----------------------- So to use this to change the transparency you could do:
for Number=0,1,0.1 do door.Transparency = Number end ------------------- Note that the increment is left blank it defaults to 1.
|
|
|
| Report Abuse |
|
|