bloberous
|
  |
| Joined: 07 Jun 2009 |
| Total Posts: 299 |
|
|
| 29 Jul 2016 08:09 AM |
I'm trying to make the text on a GUI change depending on what object your mouse is hovered over. This is what I have so far and it does not work but neither does it give me errors.
--
local mouse = player:GetMouse() local target = mouse.Target local playergui = game.Players.LocalPlayer.PlayerGui
while true do wait() text = "" if target ~= nil then if target:findFirstChild"examine" then text = "Examine" end end playergui.ScreenGui.Text.Text = text end |
|
|
| Report Abuse |
|
|
|
| 29 Jul 2016 08:15 AM |
You have to update the target. Just doing that means it'll never change after it's been assigned.
local player, mouse, playergui, target = game.Players.LocalPlayer --I just declare them all at once. Then they're local for the rest of the code. mouse = player:GetMouse() playergui = player.PlayerGui
while wait(.3) do target = mouse.Target playergui.ScreenGui.Text.Text = target and "Examine" or "" end |
|
|
| Report Abuse |
|
|
bloberous
|
  |
| Joined: 07 Jun 2009 |
| Total Posts: 299 |
|
|
| 29 Jul 2016 08:22 AM |
Thanks a lot! Never noticed it because I try to keep my script nice and clean with all stating at the start.
Also, with the local variables I never really learned the difference between the two? |
|
|
| Report Abuse |
|
|
bloberous
|
  |
| Joined: 07 Jun 2009 |
| Total Posts: 299 |
|
|
| 29 Jul 2016 08:32 AM |
| Nevermind. Don't answer that last question. Post closed. |
|
|
| Report Abuse |
|
|
|
| 29 Jul 2016 08:34 AM |
Why not script.Parent.MouseEnter:connect(function() script.Parent.Text = "B;aj" end) script.Parent.MouseLeave:connect(function() script.Parent.Text = "Return to normal..." end) You can use a local script so only client side can see the changes... |
|
|
| Report Abuse |
|
|
|
| 29 Jul 2016 10:08 AM |
bump
you cant close the post dummy
ᕦ(⊜ل͜⊜)ᕥ |
|
|
| Report Abuse |
|
|
casperm8
|
  |
| Joined: 15 Sep 2008 |
| Total Posts: 425 |
|
|
| 29 Jul 2016 10:14 AM |
| We will all see your shame.... |
|
|
| Report Abuse |
|
|