Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 20 Apr 2016 10:12 AM |
script.Parent.Touched:connect(function(hit) local h = hit.Parent:FindFirstChild("Humanoid"); if (h ~= nil) then local p = hit.Parent.Name; if p == tycoon.Owner.Value then holo.Transparency = 1; holo.Back.Enabled = false; holo.Front.Enabled = false; end else end end) This is my script to make things invisible, when player touches it. The problem is - I don't know how to make it visible back, when player doesn't touch it anymore. Where do I need to put this in?:
holo.Transparency = 0.2; holo.Back.Enabled = true; holo.Front.Enabled = true;
Thanks for your help. |
|
|
| Report Abuse |
|
|
Inigo18
|
  |
| Joined: 02 Feb 2014 |
| Total Posts: 1041 |
|
|
| 20 Apr 2016 10:28 AM |
Well, you should use a raycast, because if you do a function .Touched, it's not going to be "as long as you're touching, this happens" but, "you touch, this happens." Idk if I'm explaining myself well. Anywho, if you don't wanna do that, use TouchEnded, an event that fires when you stop touching the part. Hope I helped! |
|
|
| Report Abuse |
|
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 20 Apr 2016 11:12 AM |
| Aaand, how exactly do I do that? I didn't find something like it (or at least I don't understand it). |
|
|
| Report Abuse |
|
|
Inigo18
|
  |
| Joined: 02 Feb 2014 |
| Total Posts: 1041 |
|
|
| 20 Apr 2016 11:13 AM |
| The raycast thing or the function TouchedEnded? |
|
|
| Report Abuse |
|
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 20 Apr 2016 11:43 AM |
| I see you can't explain what raycasting is, right? Can anyone else please explain it to me? |
|
|
| Report Abuse |
|
|
|
| 20 Apr 2016 01:00 PM |
http://wiki.roblox.com/index.php?title=Ray
|
|
|
| Report Abuse |
|
|
Inigo18
|
  |
| Joined: 02 Feb 2014 |
| Total Posts: 1041 |
|
|
| 20 Apr 2016 01:02 PM |
| Have fun reading, you unappreciative kid. |
|
|
| Report Abuse |
|
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 20 Apr 2016 01:03 PM |
Yeah, I already saw that, but I don't find anything useful for my problem there.
Just shut up Inigo18 |
|
|
| Report Abuse |
|
|
Inigo18
|
  |
| Joined: 02 Feb 2014 |
| Total Posts: 1041 |
|
|
| 20 Apr 2016 01:04 PM |
| Why would I, I'm trying to help you just as this forum is about, helping you to act normal. |
|
|
| Report Abuse |
|
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 20 Apr 2016 01:05 PM |
| Sry, made a mistake, it should be "I've already seen that" |
|
|
| Report Abuse |
|
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 20 Apr 2016 01:07 PM |
| You call this helping? Just don't write any other dumb posts under my questions. The things that the world is beeging destroyed by are person like you. I hate people like this, so just don't answer to it anymore. |
|
|
| Report Abuse |
|
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 20 Apr 2016 01:07 PM |
| That's the best way you'd help me. |
|
|
| Report Abuse |
|
|
Inigo18
|
  |
| Joined: 02 Feb 2014 |
| Total Posts: 1041 |
|
|
| 20 Apr 2016 01:09 PM |
| someone is being a little ruuuuuudeeeeee. |
|
|
| Report Abuse |
|
|
|
| 20 Apr 2016 01:10 PM |
You need to make a ray from the player's HumanoidRootPart and downwards in a loop. If it hits the button, you change the buttons properties - such as making it transparent. If the ray does not hit the button, you set its transparency back to 0. Code can be found in the wiki article.
And quit being rude, please. It's not very nice to disrespect someone who's genuinely trying to help you.
|
|
|
| Report Abuse |
|
|
badfitz67
|
  |
| Joined: 03 Jun 2010 |
| Total Posts: 13165 |
|
|
| 20 Apr 2016 01:13 PM |
Have fun reading, you unappreciative kid.[2]
"THIS IS IT BOYS, WE'RE IN THE WAR NOW!" |
|
|
| Report Abuse |
|
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 20 Apr 2016 01:13 PM |
I'm just telling you the truth.
Can please anyone help me scripting it? The thing I got for now is this:
[...]
script.Parent.Touched:connect(function(hit) local h = hit.Parent:FindFirstChild("Humanoid"); if (h ~= nil) then local p = hit.Parent.Name; if p == tycoon.Owner.Value then holo.Transparency = 1; holo.Back.Enabled = false; holo.Front.Enabled = false; script.Parent.TouchEnded:connect(function(hit) holo.Transparency = 0.2; holo.Back.Enabled = true; holo.Front.Enabled = true; end) end end end)
What it does is makeing the 'holo' show itself and hide after less than one second and again show, hide, show, hide.... Thanks for helping (and not beeing that rude like Inigo18 btw) |
|
|
| Report Abuse |
|
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 20 Apr 2016 01:15 PM |
| This is good answer! Thanks Patrickblox. I'll try to do this. |
|
|
| Report Abuse |
|
|
|
| 20 Apr 2016 01:17 PM |
Firstly, you don't need the .Touched event at all. Secondly, it should probably all be done locally. Not server-sided. Thirdly, if that wiki article isn't helpful to you, there's no more we can do. It's a very well-written article, and I suggest you either read it or go learn more basic things before trying to do advanced scripting with rays.
|
|
|
| Report Abuse |
|
|
Inigo18
|
  |
| Joined: 02 Feb 2014 |
| Total Posts: 1041 |
|
|
| 20 Apr 2016 01:18 PM |
First, I believe you cannot put a function .TouchEnded in a function .Touched. Second, if you would just say, "Thank you for trying to help me", or "thank you anyways", this would've not happened. You really need to thank people that wastes their time trying to solve your problems, and not just saying "oh i see you don't know what that is" and just leave like if nothing happened. Hope THIS serves as your answer. |
|
|
| Report Abuse |
|
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 20 Apr 2016 01:27 PM |
The thing why I don't still get this is that I don't speak English that well, so I don't understand it all. I found one interesting function that could solve my problem:
Ray:Distance(Vector3 point)
But I also got other idea: checking distance from position of button to the player's position. And this is propably the way I'll do this. |
|
|
| Report Abuse |
|
|
|
| 20 Apr 2016 01:33 PM |
...that's not a very good method. Use raycasting...
local ray = Ray.new( root.Position, -- origin root.Position - Vector3.new(0, 10, 0) -- direction )
local hit, position = workspace:FindPartOnRay(ray, ignore) print(hit)
http://wiki.roblox.com/index.php/Raycasting
|
|
|
| Report Abuse |
|
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 20 Apr 2016 01:55 PM |
Why actually not? The script I'm using now is this:
if tycoon.Owner.Value ~= 'None' then if (game.Workspace[tycoon.Owner.Value].Torso.Position - script.Parent.Parent.Position).magnitude <= 5 then holo.Transparency = 1; holo.Back.Enabled = false; holo.Front.Enabled = false; else holo.Transparency = 0.2; holo.Back.Enabled = true; holo.Front.Enabled = true; end end
And it works just perfect for me. What difference would make the raycasting method? |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 20 Apr 2016 02:00 PM |
why would use use raycasting just do either gettouchingparts or magnitude
|
|
|
| Report Abuse |
|
|
|
| 20 Apr 2016 02:11 PM |
It honestly depends on how accurate it needs to be. Rays aren't very expensive to use at all, and they're really precise. That's why I'd use them, but magnitude works too. :GetTouchingParts( ) is more expensive to use than rays, so I wouldn't use it.
|
|
|
| Report Abuse |
|
|
Opisek
|
  |
| Joined: 05 Aug 2014 |
| Total Posts: 155 |
|
|
| 21 Apr 2016 01:13 PM |
| What do you mean with 'expensive'? A lot lines of code or what else? Anyway I'll just use magnitude like I'm doing right now. Thanks for help everyone |
|
|
| Report Abuse |
|
|