What I am currently trying to do is make a script that will only show up at X distance.. I know I am going to need to use Magnitude to see how far a person is from a spot. I have done some testing and I was able to create a local script within a player to see if the player was within the distance of a brick that was specified.. But specifying each brick for each gui that I would want to show would be a tedious thing. I don't want anyone to create the script for me. I would rather do it myself but I just need a few tips on how I would go about creating it. Like the idea behind it.
What i have done before was this..
wait(2)
local Player = game.Players.LocalPlayer
local Char = Player.Character.Torso
local mouse = Player:GetMouse()
local Box = game.Workspace.AmmoBox
local ammo = Box.Ammo
local maxammo = Player.MaxAmmo
local pammo = Player.Ammo
local mag = (Box.Position - Char.Position).Magnitude
local Storage = Player.Storage
local MStorage = Player.MaxStorage
function keydown(key)
key = key:lower()
print(key)
if key == "f" then
if Box then
if mag >= 10 then
if Storage.Value < MStorage.Value then
Storage.Value = Storage.Value + math.floor(MStorage.Value*.7)
end
end
end
end
end
mouse.KeyDown:connect(keydown)
how this script works is that it's inside the StarterGUI as a local script. It defines the player and the box. Defines the Magnitude of the player to the box. If the player presses the "f" key, it checks if the player is within 10 studs of the box, if so then it goes through with awarding the player ammo.
I have been thinking of ways on how to implement what I have done before to what I want to currently do and it's a bit of an odd situation for me.
What I have been thinking is something like this..
owner = script.Parent.Parent.Owner -- This defines the owner of the tycoon
player = game.Workspace:WaitForFirstChild(owner.Value) -- This currently defines the character.
Char = player.Torso
brick = script.Parent
mag = (brick.Position - Char.Position).Magnitude --gets the Magnitude
-- I don't know any way to currently effectively check automatically if the player is within a certain magnitude I am going to need some help with that.
-- If I was to try to do something it would be "mag.changed:connect" but I have no idea if that even works considering it's just a variable within the script
--What would happen after that is the GUI that is currently named "Terminal" would become visible/invisible depending on the mag. game.Players.PlayerGui.Terminal.Frame
All I would simply need is a nudge in the correct direction :D So don't take the fun out of scripting and do it for me XD The most I would ask for is a link to the wiki.

4 comments
Instead of using Magnitude, use :GetDistanceFromCharacter(brick.Position)
uhh, why is one over the other any better?
Less to type @lomo. Also, you could just have a spherical part covering the distance that you want the gui to be inserted. Insert with Touched event. Remove with TouchEnded event.
Hmm, that seems to be a decent way to do it.