I’m trying to make a bullet effect, it has a red dot that changes size based on the local player’s distance to the bullet.
But I don’t really know how to do this.
Here’s my script
local Dot = script.Parent.Dot
local Emitter = script.Parent.Dots.ParticleEmitter
function CheckPlayerDistance()
local Player = game.Players.LocalPlayer
local Char = Player.Character
Dot.Value = (Char.Position - script.Parent.Position).Magnitude
end
while true do
CheckPlayerDistance()
Emitter.Size = NumberSequence.new{
NumberSequenceKeypoint.new(0,0),
NumberSequenceKeypoint.new(1,Dot.Value)
}
wait()
end
This doesn’t seem to do anything, it doesn’t even print(“Test”), this is a local script in a part.
Local scripts don’t run in the workspace, with the exception of local scripts that are the descendants of a player’s character. I would probably use CollectionService and parent the local script to StarterPlayerScripts. Also,
Don’t reference services using ., use GetService, as it works even if the service is accidentally renamed.
You should use task.wait as it doesn’t throttle like wait
So would I use the collection service, to check if there are any parts tagged with Say: “Bullet”. If so then it sends a remote event to all players, and the local script in the players will change the dot value and size locally?