I want my player to fly at a certain speed to the specified point after running the code, it should not be teleportation, but exactly smooth movement, as in this video - https://youtu.be/_p7HmviCIF8?t=231
For your case here, if you want an exact time for every teleport, you're gonna need to use TweenService.
So you're first going to reference where you're going. Let's say that our point is a CFrame value of an object.
Remember, whenever we want to tp our character, we use CFrames and not Positions.
So first, you're gonna wanna make a TweenInfo, which is basically the parameters of the tween, e.g Time to get to the point, the movement it should have (Linear, Elastic, etc.), etc.
And then you're gonna need a table containing of the property that needs to be changed. In which case we want the CFrame value of the HumanoidRootPart to be the point we set.
Then we're going to make a new tween and have it tween our HumanoidRootPart CFrame to the point CFrame.
local TweenService = game:GetService("TweenService")
local TweeningInfo = TweenInfo.new(
-- The time to get there here
)
local TargetValue = {
CFrame = -- Point CFrame here.
}
local Tween = TweenService:Create(game.Players.LocalPlayer.Character.HumanoidRootPart, TweeningInfo, TargetValue)
Tween:Play()
For your video its just an script for a exploit like synapse x but there are a lot of pastebin or free scripts in toolbox or simply video on that or use the adonis admin on studio and run this in chat :fly me "speed"
Related
I have a few islands, where players spawn, and I need to make a wave(round like in TD games) system for every player, and, when a player leaves and then joins the game, everything should start from a wave, where the player finished. I guess I know how to save data but I really don't know how to make a separate wave system for every player, I mean, where I have to save the value of the wave number. I'm a total noob in everything so I really don't understand how starter pack changes work and server storage also. So I would be rlly happy if anyone could help with it.
Also, I know that there are module scripts and they may help here, but I don't know how can I use it here.
I have a spawner of enemies and I need to change it for the wave system
local marine = rs.Enemies.OnePiece.Marine2:Clone()
local anim = rs.EnemiesScripts:FindFirstChild("Animation"):Clone()
local move = rs.EnemiesScripts:FindFirstChild("Movement"):Clone()
local hpBar = rs.BillboardUi.HpBar:Clone()
hpBar.Parent = marine
move.Parent = marine
anim.Parent = marine
marine.Parent = workspace.Islands:WaitForChild("1").Bodies:WaitForChild("enemies")
marine.HumanoidRootPart.CFrame = marine.Parent.Parent.Parent:FindFirstChild("enemySpawner").CFrame * CFrame.new(0,10,0) * CFrame.Angles(0,3.2,0)````
I Have a bug, so script that focus camera doesn`t works in my game. But in roblox studio testing mode in works. It is Liocalscript located in StarterPlayerScripts.
That`s my script.
local cam = workspace.Camera
local cameraType = Enum.CameraType.Scriptable
cam.CameraType = cameraType
repeat
cam.CameraType = Enum.CameraType.Scriptable
until cam.CameraType == Enum.CameraType.Scriptable
while wait() do
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = workspace.CameraPart.CFrame
end
I tried making not a LocalScript. Also pasting it in ServerScriptStorage, making it local and not local script.
First off, you will always want to run this locally, since the player is the only person that's going to have a camera in a real Roblox game.
I'm assuming that you want to control the camera of the playing user with as script. If that's true, you should only need to set the CameraType property once. There's no point in using a loop there. Once you set the camera type to Scriptable, you need to set the camera's CFrame to look at the part that you're targeting.
If I had a part in the workspace called "MyPart", then I could set the camera's CFrame to look in front of it. Where you set the CFrame is your choice. One way this can be accompished is setting the position of the camera 4 studs away from the part's LookVector and look at the part.
A pseudocode example of this is shown below:
local part = workspace.MyPart
local cam = workspace.CurrentCamera
-- Set camera type
cam.CameraType = Enum.CameraType.Scriptable
-- Focus camera on part once
cam.CFrame = CFrame.new((part.CFrame + part.LookVector * 4).Position, part.Position)
If the part moved, however, you would have to compensate for that. If you plan on making the camera focus on the part dynamically, you will want to set the camera's CFrame on every frame, which can be done with RunService.RenderStepped.
Considering the fact that you're struggling a bit with the fundamentals of Roblox scripting, you may want to look a bit into Roblox's API reference and doing easier projects for the time being.
Been trying for a while now, not sure how to create a way to block players who don't have enough money to enter a zone and let players through who have enough money if not more.
I have a fully transparent part that i would like to act as the hitbox. I also have leaderstats set up and functioning.
If anyone could help, would be much appreciated :)
This is a great use-case for PhysicsService's CollisionGroups.
You can set up a CollisionGroup where objects in one group do not collide with those in another. It's often used for engine optimizations when a lot of objects simply don't need to check whether they need to collide with others, but you can definitely use them for this as well.
For this case, we'll set the door to be in one collision group, and every player that has unlocked the door will be in another. When they touch the door, it will check how much money they have, and if they have enough it will add each part of their character model into the unlocked group. This will allow their character model to phase right through the door.
So, in order to make this work, I added a Script to the Part that I was using for the door, and I added this code :
local PhysicsService = game:GetService("PhysicsService")
local Players = game:GetService("Players")
local COST_TO_ENTER = 10 -- update with the actual cost to open the door
local DOOR_GUID = game.HttpService:GenerateGUID()
local LOCKED_DOOR_ID = "LockedDoor" .. DOOR_GUID
local ALLOWED_PLAYERS_ID = "UnlockedPlayers" .. DOOR_GUID
-- find the door that we'll be unlocking
local door = script.Parent
-- create a collision group for the door, and another for players that have unlocked it
PhysicsService:CreateCollisionGroup(LOCKED_DOOR_ID)
PhysicsService:CreateCollisionGroup(ALLOWED_PLAYERS_ID)
-- add the door to the door's collision group
PhysicsService:SetPartCollisionGroup(door, LOCKED_DOOR_ID)
-- make it so that character models in the unlocked group don't collide with the door
PhysicsService:CollisionGroupSetCollidable(LOCKED_DOOR_ID, ALLOWED_PLAYERS_ID, false)
-- listen for when players touch the door to see if we should unlock it
door.Touched:Connect(function(otherPart)
local player = Players:GetPlayerFromCharacter(otherPart.Parent)
if player then
if player.leaderstats.Money.Value >= COST_TO_ENTER then
-- if they have enough money, add their character model to the allowed player collision group
for _, part in ipairs(player.Character:GetDescendants()) do
if part:IsA("BasePart") then
PhysicsService:SetPartCollisionGroup(part, ALLOWED_PLAYERS_ID)
end
end
-- TODO : update the visuals of the door client-side so that players know that it is unlocked for them
end
end
end)
-- clean up if the door is getting deleted
door.Destroying:Connect(function()
PhysicsService:RemoveCollisionGroup(LOCKED_DOOR_ID)
PhysicsService:RemoveCollisionGroup(ALLOWED_PLAYERS_ID)
end)
This system doesn't persist whether a player has unlocked the door. So if your character dies, they may need to have enough money to get back in again. But it would be fairly simple to add a receipt system that keeps track which players have unlocked it, and re-add character models to the collision group upon respawn.
Not Enough Money
Enough Money
Every time the money changes, you would also change the CanCollide property of the hitbox. For example:
money.Changed:Connect(function()
hitbox.CanCollide = money.Value < 1024
end)
Here, the < operator will return true if the value of money is smaller than 1024, false otherwise. So if the amount of money is small, the block will collide with the player (not letting him/her in), but otherwise it doesn't.
You would do that in the client so that it only applies to that specific client, not all clients.
Protecting it from cheaters isn't necessary in this case, Roblox characters themselves are exploitable. If you're making an anti-cheat, you can make these zones impossible to enter by teleporting the player to their previous position if they enter when they shouldn't be able to.
I already tried looking up multiple solutions in the Roblox developer forums, but I only found some unfinished code or some code that didn't work with mine. The code in this picture makes my rig find the part and chase it until it's there. That works perfectly, but I've been trying to find a way for the rig to chase the nearest player instead. I've heard of magnitude, but I'm not sure how to implement it, I cant even make the rig chase a player in the first place.
First off, .magnitude is the "length of a vector". It is mostly used to find the distance in vector units from pointA to pointB. Hence, the distance from the 2 points would be (pointA.Position-pointB.Position).magnitude.
https://developer.roblox.com/en-us/articles/Magnitude
Now in order to chase the players, you can loop through all of the players and get the one your NPC will chase.
You can use a for loop and loop through game.Players:GetPlayers() then get their character: <v>.Character and then their HumanoidRootPart which has their position. If you wanted to have a range for your NPC or an 'aggro distance', this is where you can implement magnitude. You would first create a variable for your distance. Since we will be dealing with vector units, it should be in length of vectors. For example local aggroDistance = 30. When added to the code, this would mean that it would only track a player if they are within 30 studs. You would then put an if statement saying if (<NPC.HumanoidRootPart.Position-<players hrp position>).magnitude < aggroDistance then. Now you could use Pathfinding Service to move the NPC to the player by using PathfindingService:ComputeAsync(<NPC HumanoidRootPart Position, <player HumanoidRootPart Position>) :ComputeAsync() makes a path from the starting position (the first parameter) to the end position (the second parameter). <NPC Humanoid>:MoveTo(<player HumanoidRootPart Position>) then makes the NPC move to the player. In order to listen out for when the NPC has reached the end of the path it made in :ComputeAsync() you can do <NPC Humanoid>:MoveToFinished:Connect(function()) to run a function after it reached the end, or <NPC Humanoid>:MoveToFinished:Wait() to wait before computing the next path.
Tip: You might also want to check if the player has more than 0 health (if they are alive) so the NPC only moves to players who are alive. You can do this by adding a and <player>.Humanoid.Health > 0 in the if statement where you had your aggroDistance.
Please let me know if you have any questions.
Code Makeup:
aggroDistance variable < optional
while loop
if statement (can contain aggroDistance variable if you have one) and check player health
:ComputeAsync()
:MoveTo()
:MoveToFinished
if statement end
while loop end
I am using the lua love engine to make a simple game. However, im having a little trouble with collision.
I have a polyline between a set of points (representing the rocky ground) and a box I need to collide with it, but I cant think of an easy implementation.
love.graphics.line( 0,60, 100,70, 150,300, 200,230, 250,230, 300,280, 350,220, 400,220, 420,150, 440,140, 480,340 )
If anyone could help with code snippets or advice, it would be much appreciated.
You need to create a more abstract representation of the ground, from which you can generate both the line for the graphics, and the body for the physics.
So for example:
--ground represented as a set of points
local ground = {0,60, 100,70, 150,300, 200,230, 250,230, 300,280, 350,220, 400,220, 420,150, 440,140, 480,340}
This may not be the best representation, but I will continue with my example.
You now have a representation of the ground, now you a way of converting that something that your physics can understand (to do the collision) and something that your graphical display can understand (do draw the ground). So you declare two functions:
--converts a table representing the ground into something that
--can be understood by your physics.
--If you are using love.physics then this would create
--a Body with a set PolygonShapes attached to it.
local function createGroundBody(ground)
--you may need to pass some additional arguments,
--such as the World in which you want to create the ground.
end
--converts a table representing the ground into something
--that you are able to draw.
local function createGroundGraphic(ground)
--ground is already represented in a way that love.graphics.line can handle
--so just pass it through.
return ground
end
Now, putting it all together:
local groundGraphic = nil
local groundPhysics = nil
love.load()
groundGraphic = createGroundGraphic(ground)
physics = makePhysicsWorld()
groundPhysics = createGroundBody(ground)
end
love.draw()
--Draws groundGraphic, could be implemented as
--love.graphics.line(groundGraphic)
--for example.
draw(groundGraphic)
--you also need do draw the box and everything else here.
end
love.update(dt)
--where `box` is the box you have to collide with the ground.
runPhysics(dt, groundPhysics, box)
--now you need to update the representation of your box graphic
--to match up with the new position of the box.
--This could be done implicitly by using the representation for physics
--when doing the drawing of the box.
end
Without knowing exactly how you want to implement the physics and the drawing, it is hard to give more detail than this. I hope that you use this as an example of how this code could be structured. The code that I have presented is only a very approximate structure, so it will not come close to actually working. Please ask about anything that I have been unclear about!