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

Is it possible to make a click to move?

Asked by
KoreanBBQ 301 Moderation Voter
9 years ago

A little like old green disc. But with pathfinding.

How could I disable WASD movement and keep the custom roblox Animate script?

0
It's possible, I saw someone make the old green disc thing but idk how NotSoNorm 777 — 9y

1 answer

Log in to vote
1
Answered by
dyler3 1510 Moderation Voter
9 years ago

It is actually possible to make this, and not as complicated as it might seem.


I've already made one of these myself in the past. You simply would need to find where the players mouse is, then make the green disc follow it.

To move the player, you just find the discs position, and tell the Humanoid to walk there. He's the script I came up with (Make sure this is in a LocalScript inside the PlayerGui) :

repeat wait() until game.Players.LocalPlayer
Plr=game.Players.LocalPlayer
repeat wait() until Plr.PlayerScripts
repeat wait() until Plr.PlayerScripts.ControlScript
Plr.PlayerScripts.ControlScript:remove()
Mouse=Plr:GetMouse()
repeat wait() until Plr.Character
Char=Plr.Character

local Bin=Instance.new("Message")
Bin.Name="LocalBin" --Makes the part a 'LocalPart' so only you can see it.
Bin.Parent=Char
Hover=Instance.new("Part",Bin)
Hover.Name=Plr.Name.."'s Hover Block"
Hover.FormFactor="Custom"
Hover.Size=Vector3.new(3,.2,3)
Hover.CanCollide=false
Hover.Anchored=true
Hover.BrickColor=BrickColor.new("Lime green")
Mouse.TargetFilter=Hover
Mesh=Instance.new("CylinderMesh",Hover)

function HoverUpdate(Mouse) --Sets up function to update position
    if Mouse.Target then
        X=Mouse.Hit.X
        Y=Mouse.Hit.Y
        Z=Mouse.Hit.Z
        X2=Plr.Character.HumanoidRootPart.Position.X
        Y2=Plr.Character.HumanoidRootPart.Position.Y
        Z2=Plr.Character.HumanoidRootPart.Position.Z
        DisX=math.abs(X-X2)
        DisY=math.abs(Y-Y2)
        DisZ=math.abs(Z-Z2)
        Distance=DisX+DisY+DisZ
        if Distance<=100 then
            Hover.Position=Vector3.new(Mouse.Hit.X,Mouse.Hit.Y+.2,Mouse.Hit.Z)
            Hover.Transparency=0
        else
            Hover.Transparency=1
        end
    else
        Hover.Transparency=1
    end
end

Mouse.Move:connect(function() --Updates disc position
    PlrMouse=Plr:GetMouse()
    HoverUpdate(PlrMouse)
end)

Plr.Character.Torso.Changed:connect(function() --Updates disc position
    PlrMouse=Plr:GetMouse()
    HoverUpdate(PlrMouse)
end)

Mouse.Button1Down:connect(function() --Moves character to target position
    if Mouse.Target~=nil and Hover.Transparency==0 then
        Char.Humanoid.WalkToPoint=Hover.Position
    end
end)

Mouse.KeyDown:connect(function(Key) --Replication of 'Jump' button.
    if Key==" " then
        local Space=true
        repeat wait()
            Mouse.KeyUp:connect(function(Key)
                if Key==" " then
                    Space=false
                end
            end)
            Char.Humanoid.Jump=true
        until Space==false
    end
end)

So basically, this script will work to remove the controls, and to make the green disc for movement.


However, to make the Pathfinding, you'll need to work on that on your own. Sorry, I simply have no idea to how to use it.

You'll need nodes for whatever map you're using, and for the player to move to them if an object blocks the path that the character is currently walking on.


Anyways, I hope I helped. If you have any further questions/problems, please leave a comment below. Hope I helped :P

0
I'm good with the pathfinding, thanks for the help about the Disc. However I manipulated camera so its a top-down view constantly. Idk if that's why, but mouse.hit.p isn't accurately showing where my mouse is pointing, its like a little decalled idk. KoreanBBQ 301 — 9y
0
Wait nvm its working KoreanBBQ 301 — 9y
0
Oh, ok. Well, glad I could help! :P dyler3 1510 — 9y
0
doesnt owkr Koley_Moley -7 — 4y
Ad

Answer this question