|
| 23 Aug 2015 12:19 PM |
| Hello.In a game I am developing,I was stumped in the middle of creating a map.I was adding windows into a frame.When I went to add a script to it,I realized I have no idea how to do this.I am trying to make the glass break (or "shatter") when it is shot or knifed (as seen in "Impulse Testing" by Rhyles).The current breakable glasses in the toolbox break when ANYTHING,including the player itself,touches the glass.Any help on how to make glass break ONLY when shot,knifed,or when an explosion happens near it?Thanks. |
|
|
| Report Abuse |
|
|
sparker22
|
  |
| Joined: 11 Mar 2010 |
| Total Posts: 846 |
|
|
| 23 Aug 2015 12:22 PM |
| Modify the code as a function that you call when one of those actions occur. Pretty self explanatory. |
|
|
| Report Abuse |
|
|
TwoRivers
|
  |
| Joined: 25 Aug 2011 |
| Total Posts: 2821 |
|
|
| 23 Aug 2015 12:24 PM |
| He means modifying the gun handling / knife stabbing. |
|
|
| Report Abuse |
|
|
|
| 23 Aug 2015 12:24 PM |
| How would I detect the collision,though?The bullet part,I know how to do.But an explosion detection? |
|
|
| Report Abuse |
|
|
Aspected
|
  |
| Joined: 20 Feb 2015 |
| Total Posts: 3 |
|
|
| 23 Aug 2015 12:25 PM |
send me your code, i'll help you
while true do print("lol") end |
|
|
| Report Abuse |
|
|
|
| 23 Aug 2015 12:27 PM |
explosion.Hit:connect(function(part, distance) --if part is a piece of glass and distance < n --break it --end end)
~Upload code to codepad-dot-org with Lua syntax highlighting to preserve indentation and make it easier to read!~ |
|
|
| Report Abuse |
|
|
|
| 23 Aug 2015 12:28 PM |
Here.
local Player=game.Players.LocalPlayer local Glass = script.Parent local DecalBack = Glass["BackD"] local DecalFront = Glass["FrontD"] local TextureId = Glass.Texture local broken = false
function onTouched(part) local h=game.Players:GetPlayerFromCharacter(part.Parent) if h==nil then if broken == false then broken = true --DecalBack.Texture = TextureId.Value --DecalFront.Texture = TextureId.Value elseif broken == true then local items = script.Parent.Parent:GetChildren() for i,k in pairs(items) do if k.Name == "ShowUp" then k.Anchored=false k.Transparency = 0.6 k.CanCollide = true Glass.Transparency=1 Glass.CanCollide=false end end
end end end
Glass.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
|
| 23 Aug 2015 12:28 PM |
waat explosion fires a hit event? TIL
while true do the do |
|
|
| Report Abuse |
|
|
TwoRivers
|
  |
| Joined: 25 Aug 2011 |
| Total Posts: 2821 |
|
|
| 23 Aug 2015 12:29 PM |
| it's one of those events you don't realize exists until you happen to look on its wiki page |
|
|
| Report Abuse |
|
|
|
| 23 Aug 2015 12:31 PM |
| @Aspected my code has been posted. |
|
|
| Report Abuse |
|
|
|
| 23 Aug 2015 12:32 PM |
Chief?
while true do the do |
|
|
| Report Abuse |
|
|
| |
|
TwoRivers
|
  |
| Joined: 25 Aug 2011 |
| Total Posts: 2821 |
|
| |
|
| |
|
| |
|