ajm1996Top 100 PosterJoin Date: 2007-08-14 Post Count: 13837 |
Can you please edit this script I need it right away for my place. The problem is that it only works once, and then when I try it again it won't work, and I have to get off and back on for it to work.
Here it is:
function onTouched(hit)
building = game.Workspace.Building1.side1
backup = game.Workspace.Building1.side1:clone()
building:remove()
wait(3)
building = backup:clone()
building.Parent = game.Workspace.Building1
building.Name = "side1"
building.Anchored = true
building.Locked = false
model:makeJoints()
end
script.Parent.Touched:connect(onTouched) |
|
ajm1996Top 100 PosterJoin Date: 2007-08-14 Post Count: 13837 |
please help I need to finish my place. |
|
koopaJoin Date: 2006-11-07 Post Count: 1028 |
I would try something more like this:
--------------------
backup = game.Workspace.Building1.side1:clone()
function onTouched(hit)
game.Workspace.Building1.side1:remove()
wait(3)
building = backup:clone()
building.Parent = game.Workspace.Building1
building.Name = "side1"
building.Anchored = true
building.Locked = false
building:makeJoints()
end
script.Parent.Touched:connect(onTouched)
-----------------------
I would have the lines that states what backup is outside of the onTouched function. If you have it inside the onTouched function then it will only do that when touched. So it will create a clone of side1 when it has been touched. If you keep it outside of that then as soon as the game starts it already has a copy of it. It is really up to you though. I find that doing that keeps it a little simpler, and works in more situations.
I think the problem with the script was actually your last statement before the end of the onTouched function. You had "model:makeJoints()" At that point model wasn't anything since you didn't make it anything. Thus it would break at that line.
Koopa |
|
ajm1996Top 100 PosterJoin Date: 2007-08-14 Post Count: 13837 |
I already tried it without the model:makeJoints()
and it didn't work I replaced my with yours but it still only works once. |
|
ajm1996Top 100 PosterJoin Date: 2007-08-14 Post Count: 13837 |
I'm getting frustrated this stupid thing won't work! |
|
ajm1996Top 100 PosterJoin Date: 2007-08-14 Post Count: 13837 |
Please help and if yours works and your in the builders club I will pay you 50 tixs. |
|
koopaJoin Date: 2006-11-07 Post Count: 1028 |
I have a question. Is your model already locked and anchored? The one that you are cloning? And since it is actually already named side1 you could just have it like...
--------------------
backup = game.Workspace.Building1.side1:clone()
function onTouched(hit)
game.Workspace.Building1.side1:remove()
wait(3)
building = backup:clone()
building.Parent = game.Workspace.Building1
building:makeJoints()
end
script.Parent.Touched:connect(onTouched)
-----------------------
Koopa |
|
ajm1996Top 100 PosterJoin Date: 2007-08-14 Post Count: 13837 |
I think it's anchored and it's not lock but I just put that in case. I will try yours tomorrow I have to go to bed. |
|
ajm1996Top 100 PosterJoin Date: 2007-08-14 Post Count: 13837 |
It didn't work. |
|
CoolJBJoin Date: 2007-10-17 Post Count: 1737 |
backup = game.Workspace.Building1.side1:clone()
function onTouched(hit)
local human = hit.Parent:findFirstChild("Humanoid")
if human ~= nil then
game.Workspace.Building1.side1:remove()
wait(3)
building = backup:clone()
building.Parent = game.Workspace.Building1
building:makeJoints()
end
script.Parent.Touched:connect(onTouched)
------------------------------------------------------------------------
Um...Humanoid?
C=CoolJB=C
(It might work.) |
|
CoolJBJoin Date: 2007-10-17 Post Count: 1737 |
I forgotted to put a second end,the if action. |
|
ajm1996Top 100 PosterJoin Date: 2007-08-14 Post Count: 13837 |
where do you put the if action |
|
ajm1996Top 100 PosterJoin Date: 2007-08-14 Post Count: 13837 |
That only work once too. |
|
ajm1996Top 100 PosterJoin Date: 2007-08-14 Post Count: 13837 |
can I make it so it deletes the script and then clones it so it's just like I quit and got back on. |
|
koopaJoin Date: 2006-11-07 Post Count: 1028 |
Ok, so i know what your problem is now. I thought it was a error inside the script.
So, i'll tell you what is going on. When you touch the brick it does the onTouched function because that is what we have it set to do. Now the problem is what happens if we touch the brick again, while it is still doing onTouched function for the last time we touched it? The script would break when it tried to remove side1 from the game because it could no longer find side1. It could no longer find side1 because on our last touch we had already removed it.
To fix a problem like this you can just add a debounce.
-----------------------
backup = game.Workspace.Building1.side1:clone()
debounce = false
function onTouched(hit)
if debounce == false then
debounce = true
game.Workspace.Building1.side1:remove()
wait(3)
building = backup:clone()
building.Parent = game.Workspace.Building1
building.Name = "side1"
building.Anchored = true
building.Locked = false
building:makeJoints()
debounce = false
end
end
script.Parent.Touched:connect(onTouched)
-------------------------
So the debounce only allows the onTouched function to start up again after the last one has ended. By using this it will always be able to find side1.
Koopa |
|
|
while true do -- Infinate Loop might go more than once. :P
backup = game.Workspace.Building1.side1:clone()
function onTouched(hit)
game.Workspace.Building1.side1:remove()
wait(3)
building = backup:clone()
building.Parent = game.Workspace.Building1
building.Name = "side1"
building.Anchored = true
building.Locked = false
building:makeJoints()
end
script.Parent.Touched:connect(onTouched)
________________________________________
Try that.
|
|
ajm1996Top 100 PosterJoin Date: 2007-08-14 Post Count: 13837 |
It didn't work koopa and I thought you said not to put in building:MakeJoints |
|
koopaJoin Date: 2006-11-07 Post Count: 1028 |
Hmm... I tried it out, works fine for me. Did you use my script or Dogsrocks' script? His script will not work.
No, having the building:makeJoints() is fine. You will most likely need that unless the model is anchored to begin with.
Koopa |
|
ajm1996Top 100 PosterJoin Date: 2007-08-14 Post Count: 13837 |
it is anchored I think and it won't work for me idk y. |
|
ajm1996Top 100 PosterJoin Date: 2007-08-14 Post Count: 13837 |
koppa how about I make it a public model for a littel bit until u fix it and then you make it a public model and then delete it later? |
|
ajm1996Top 100 PosterJoin Date: 2007-08-14 Post Count: 13837 |
will you koopa? |
|
|
umm arent u forgeting debounce? |
|
ajm1996Top 100 PosterJoin Date: 2007-08-14 Post Count: 13837 |
koopa suggested that but it won't work. |
|