|
| 18 Nov 2016 05:34 PM |
Hi, I'm trying to make a billboard GUI that only appears when the player is within a certain distance, and I'm unsure of what variable to use for it, I thought it was "MaxDistanceFromPlayer" or something, but I'm not sure of how to do it. I thought it would be something like this.
while true do if MaxDistanceFromPlayer < 50 then game.Workspace.Thing.TinyThing.BillBoardGUI.TextBox.Visible = true end end
But I'm not sure. |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2016 05:38 PM |
It's DistanceFromCharacter and if you wanna do an infinite loop at-least use a wait().
http://wiki.roblox.com/index.php?title=API:Class/Player/DistanceFromCharacter
|
|
|
| Report Abuse |
|
|
|
| 18 Nov 2016 05:55 PM |
I'm trying to mess with it, but I'm still not exactly getting what I want.
while true do if game.Workspace.Campfire.Part.Position.X.DistanceFromPlayer < 50 then game.Workspace.Campfire.Part.BillboardGui.TextBox.Visible = true wait() end end |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2016 06:03 PM |
| Don't hav time to read it in csgo game but its :DistanceFromPlayer not .DistanceFromPlayer |
|
|
| Report Abuse |
|
|
| |
|
doggy00
|
  |
| Joined: 11 Jan 2011 |
| Total Posts: 3571 |
|
|
| 18 Nov 2016 06:29 PM |
--you'd need to put this in a local script
player = game.Players.LocalPlayer name = player.Name
while true do wait() char = workspace:WaitForChild(name) if player.Character ~= nil then --just in case someone in the game is named after something in workspace torso = player.Character:WaitForChild("Torso") local magnitude = (workspace.Thing.TinyThing.Position - torso.Position).magnitude if magnitude < 50 then game.Workspace.Thing.TinyThing.BillBoardGUI.TextBox.Visible = true end end end
--i know this is really sloppy, i'm a sloppy scripter, but this should work |
|
|
| Report Abuse |
|
|
doggy00
|
  |
| Joined: 11 Jan 2011 |
| Total Posts: 3571 |
|
|
| 18 Nov 2016 06:30 PM |
| oh, and of course make it invisible again if the magnitude is greater than/equal to 50. |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2016 06:51 PM |
ok now that I've finished my game and owned some newbs i can explain the method that i gave you.
So what you're doing whether you use the other guys code or not will only work on a server with 1 player on and I'm not sure if that's what you want. Doing what the other guy did (assuming its correct) using the method i gave you will go something like this:
part = game.Workspace.Thing
while wait() do
for _, player in pairs(game.Players:GetPlayers()) do if player:DistanceFromCharacter(part.Position) <= 50 then game.Workspace.Thing.TinyThing.BillBoardGUI.Enabled = true else game.Workspace.Thing.TinyThing.BillBoardGUI.Enabled = false end end end
To make it work with multiple people on the server you would have to put the gui in StarterGui and set its Adornee property to the part 'thing' then you would use this code:
part = game.Workspace.Thing
while wait() do
for _, player in pairs(game.Players:GetPlayers()) do if player:DistanceFromCharacter(part.Position) <= 50 then player.PlayerGui.BillboardGui.Enabled = true else player.PlayerGui.BillboardGui.Enabled = false end end end
I am assuming that 'Thing' is a part in workspace and not a model name so change it if you need to and I'm sure you can figure out the rest. |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2016 07:07 PM |
| Ok, so I made a local script and pasted the multiple people thing into it, but it still isn't really doing anything, I did the rest of the steps correctly though. |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2016 07:14 PM |
| It works fine for me so tell me what is going wrong, what errors come up in the console, where you have put the script and gui and if you are testing it using a test server or not |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2016 07:17 PM |
OK, So its in workspace. And one error comes up when run through Output: 18:16:12.401 - BillboardGui is not a valid member of PlayerGui, and this is in studio.
1 more thing, the "Thing" is a model, its actually a campfire that I made. |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2016 07:22 PM |
Change part = game.Workspace.Thing to part = game.Workspace.Thing.TinyThingy
move the billboard Gui to StarterGui and set the Adornee property to the TinyThingy part. |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2016 07:27 PM |
| I've done that, and still does not work sadly. Sorry if this is getting difficult. |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2016 07:28 PM |
| Is the script supposed to be in the BillboardGUI or somewhere else? |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2016 07:28 PM |
nvm use this:
for _, player in pairs(game.Players:GetPlayers()) do if player:DistanceFromCharacter(part.Position) <= 50 then player.PlayerGui.BillboardGUI.Enabled = true else player.PlayerGui.BillboardGUI.Enabled = false end end end
|
|
|
| Report Abuse |
|
|
|
| 18 Nov 2016 07:29 PM |
| honestly i think it can be anywhere tbh. I put it in ServerScriptService first then moved it in a localscript to playergui then moved it again inside the BillboardGui |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2016 07:33 PM |
| Output still says BillboardGUI is not a valid member of PlayerGUI. :| |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2016 07:35 PM |
lol try this:
part = game.Workspace.Thing.TinyThingy
for _, player in pairs(game.Players:GetPlayers()) do if player:DistanceFromCharacter(part.Position) <= 50 then player.PlayerGui.BillBoardGUI.Enabled = true else player.PlayerGui.BillBoardGUI.Enabled = false end end end |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2016 07:46 PM |
| Eureka! It worked! Thanks so much for the help! :) |
|
|
| Report Abuse |
|
|
| |
|