Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[SOLVED]Why is the trail size smaller than expected?

Asked by 6 years ago
Edited 6 years ago

I am trying to make a click to move script, and it works fine but I tried making a trail of the path the player will be taking, but it failed horribly.

LocalScript:

Plr=game.Players.LocalPlayer
Plr.PlayerScripts.ControlScript:Destroy()
Mouse=Plr:GetMouse()
repeat wait() until Plr.Character
Char=Plr.Character
CircleMesh = game.ReplicatedStorage.CircleMesh
local Secret=Instance.new("Message")
Secret.Name="Local"
Secret.Parent=Char
Hover=Instance.new("Part")
Hover.Parent = Secret
Hover.Name=Plr.Name.."'s Hover Block"
Hover.FormFactor="Custom"
Hover.Size=Vector3.new(3,.2,3)
Hover.CanCollide=false
Hover.Anchored=true
Hover.Transparency = 1
Mouse.TargetFilter=Hover

Mouse.Button1Down:Connect(function() --Moves character to target position
 if Plr.Character.Humanoid.Health ~=0 and Plr.Character.Humanoid.Health >= 5 then
   Char.Humanoid.WalkToPoint=Hover.Position 
   local Trail = Instance.new("Part")
   Trail.Parent = Hover
   Trail.Name = "Trail"
   Trail.CanCollide = false
   Trail.Anchored = false
   Trail.BrickColor=BrickColor.new("Lime green") 
   Trail.Size = Vector3.new(1,2,Hover.Position - Plr.Character.LowerTorso.Position)
   print(Trail.Size)    

It always printed: 1, 2, 0.0500000007, any ideas?

0
Well the size will most likely always be the same because the hover position is never updated to any new value. Try updating the position of Hover on a onMouseHover event. Impacthills 223 — 6y
0
Do you mean Mouse.Move? mixgingengerina10 223 — 6y
0
Yes try using that event and keep updating the hovers position with the mouse x, y Impacthills 223 — 6y
0
I tried this : Hover.Position=Vector3.new(Mouse.Hit.X,Mouse.Hit.Y,Mouse.Hit.Z), still the same number mixgingengerina10 223 — 6y
View all comments (3 more)
0
Ok, I Figured out a way, Here's the script now local X=Mouse.Hit.X local Y=Mouse.Hit.Y local Z=Mouse.Hit.Z local X2=Plr.Character.HumanoidRootPart.Position.X local Y2=Plr.Character.HumanoidRootPart.Position.Y local Z2=Plr.Character.HumanoidRootPart.Position.Z local DisX=math.abs(X-X2) local DisY=math.abs(Y-Y2) local DisZ=math.abs(Z-Z2) mixgingengerina10 223 — 6y
0
local Distance=DisX+DisY+DisZ mixgingengerina10 223 — 6y
0
Trail.Size = Vector3.new(1,2,Distance) mixgingengerina10 223 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

I think you forgot last number in Trail.Size - Vector3.new in Studio 0.05 it's minimal number

0
Trail.Size = Vector3.new(1,2,Hover.Position - Plr.Character.LowerTorso.Position) .... mixgingengerina10 223 — 6y
Ad

Answer this question