tarrdoJoin Date: 2008-06-24 Post Count: 476 |
So there is a script to do Distance From Character but I dont know how to use it.
I would like to be able to learn how to script it so I can script distance from character to NPC to open a shop. |
|
|
I'm on an iPad so excuse any errors.
local dist = 5
while wait() do
If (part1.Position - part2.Position).magnitude <= dist then
print'within range'
end |
|
|
Whoops
local dist = 5
while wait() do
If (part1.Position - part2.Position).magnitude <= dist then
print'within range'
end
end |
|
cntkillmeJoin Date: 2008-04-07 Post Count: 49450 |
Or if you are comparing a character to a position, you could do
if player:DistanceFromCharacter(part.Position) <= dist then
as opposed to subtracting the Torso.Position and part.Position and using the Magnitude member |
|
tarrdoJoin Date: 2008-06-24 Post Count: 476 |
local dist = 5
while wait() do
If (character.Position - BlackSmith.Torso.5.82,4.1,-26.682).magnitude
then script.Parent.Parent.Parent.StarterGui:findFirstChild("PrimaryShop")
game.StarterGui.ScreenGui.PrimaryShop.Visible = True
end
end
Would this work? |
|
cntkillmeJoin Date: 2008-04-07 Post Count: 49450 |
No.
Character is undefined, BlackSmith is undefined, incorrect conditional syntax, True should be true. |
|
tarrdoJoin Date: 2008-06-24 Post Count: 476 |
local dist = 5
while wait() do
If (character.Position - BlackSmith.5.82,4.1,-26.682).magnitude
then script.Parent.Parent.Parent.StarterGui:findFirstChild("PrimaryShop")
game.StarterGui.ScreenGui.PrimaryShop.Visible = true
else game.StarterGui.ScreenGui.PrimaryShop.Visible = false
end
end
My-primaryshop-visible-is-off-and-I-want-it-only-to-be-visble-when-near-blacksmith-else-false. -- sorry-bout-this-roblox-keeps-saying-theres-an-innapropriate-word-in-this |
|
tarrdoJoin Date: 2008-06-24 Post Count: 476 |
I can't post the part thats important that says what character is and BlackSmith apparently it has swears in it and no matter how many dashes or commas or periods I put in it its still a swear |
|
128GBJoin Date: 2014-04-17 Post Count: 8056 |
pastebin or twitter pls |
|
tarrdoJoin Date: 2008-06-24 Post Count: 476 |
https://twitter.com/MikeATCerqueira/status/491739797908500480 |
|
128GBJoin Date: 2014-04-17 Post Count: 8056 |
Why are you using == and not =?
And why are you setting a variable to a PlayerAdded event?
Also
local Blacksmith = Workspace["Black/Smith"] |
|
tarrdoJoin Date: 2008-06-24 Post Count: 476 |
what did you put it as black/smith? |
|
tarrdoJoin Date: 2008-06-24 Post Count: 476 |
ignore that I forgot to remove that / from it :P |
|
tarrdoJoin Date: 2008-06-24 Post Count: 476 |
I don't know how to link character otherwise thats why I used playerAdded |
|
tarrdoJoin Date: 2008-06-24 Post Count: 476 |
bump |
|
tarrdoJoin Date: 2008-06-24 Post Count: 476 |
bump |
|
tarrdoJoin Date: 2008-06-24 Post Count: 476 |
bump |
|