Hello. I'm trying to make a game based on tornadoes, and I used particle effects to create a realistic looking tornado. The only downfall with this is that particle effects are only visible within a certain short distance. What I am trying to do is make the base part for the tornado visible to a specific player once they get to far to see the particle effects, and invisible again when they can be seen. I know that I would have to work with a local script to do this, but I can't figure out anything. Any ideas?
Put this in a local script in StarterPlayerScripts.
local myself = game.Players.LocalPlayer local distanceToSeeTornado = 100 --Change this to whatever distance. local gameStarted = true --Putting this in if you wanted a minigame sorta game. Make sure to modify this variable and set it accordingly to your minigame setup. while true do if gameStarted then local tornado = workspace:FindFirstChild("TornadoPart") --Rename tornado part to whatever the base part is supposed to be named. if myself:DistanceFromCharacter(tornado.Position) <= distanceToSeeTornado then tornado.Transparency = 0 --Alternatively, you could replace 0 with 1 - (distanceToSeeTornado - myself:DistanceFromCharacter(tornado.Position))/100, though I'm not fully sure if that'll work. else tornado.Transparency = 1 end end wait() end
If you don't need the minigame structure, just remove the gameStarted Variable and the 'if statement' used with it.
I have managed to create my own script. It still doesn't work, but maybe this could give a good start to anyone trying to answer.
local funnel = script.Parent --Directory to base tornado part game.Players.PlayerAdded:Connect(function(player) --Starts when a player joines the game local Player = game:GetService("Players").LocalPlayer.Name local Character = workspace:FindFirstChild(Player) while true do if Character.UpperTorso then --Uses r15 characters local magnitude = (Character.UpperTorso.Position - workspace.Tornado.Funnel.Position).Magnitude --Uses magnitude instead of "DistanceToPlayer" if magnitude > 600 then --Distance I want tornado to be visible past funnel.Transparency = 0 else funnel.Transparency = 1 end wait(1) --There are lot's of other things going on, so secondly updating would be better end end end)