Mail.ruПочтаМой МирОдноклассникиВКонтактеИгрыЗнакомстваНовостиКалендарьОблакоЗаметкиВсе проекты

Дайте скрипт на роблокс

Дмитрий Царёв Ученик (104), открыт 1 неделю назад
Можете дать скрипт на притяжение игроков к сфере я хочу сделать режим типо про планету а она круглая и я не хочу что бы игрок падал когда доходил до соседнего полюса а что бы везде ходил и как бы был прикреплен к планете знаете такой скрипт ?
2 ответа
wda wdas Мыслитель (5239) 1 неделю назад
 local player = game.Players.LocalPlayer 
local planet = game.Workspace.Planet

local function onStep()
local distance = (player.Character.HumanoidRootPart.Position - planet.Position).Magnitude
local force = (planet.Position - player.Character.HumanoidRootPart.Position).Unit * (distance / 10)
player.Character.HumanoidRootPart.Velocity = force
end

game.Players.LocalPlayer.CharacterAdded:Connect(function()
game.Players.LocalPlayer.Character.HumanoidRootPart.Anchored = true
end)

game.Workspace.Planet.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:FindFirstChild(hit.Parent.Name)
if player then
player.Character.HumanoidRootPart.Anchored = true
end
end
end)

game.Players.LocalPlayer.CharacterRemoving:Connect(function()
game.Players.LocalPlayer.Character.HumanoidRootPart.Anchored = false
end)
Дмитрий ЦарёвУченик (104) 1 неделю назад
спасибо попробую
Милана Просветленный (24912) 1 неделю назад
 -- Прикрепите этот скрипт к объекту, который представляет вашу планету 

local Planet = script.Parent -- Убедитесь, что этот скрипт прикреплен к объекту-планете

local gravityStrength = 500 -- Сила гравитации, можете настроить по своему вкусу
local gravityRange = 100 -- Радиус действия гравитации

local function attractPlayer(player)
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local rootPart = character:FindFirstChild("HumanoidRootPart")

if not rootPart then return end

local direction = (rootPart.Position - Planet.Position).Unit
local force = direction * gravityStrength

humanoid:ChangeState(Enum.HumanoidStateType.FallingDown)
humanoid.WalkSpeed = 0 -- Можно оставить или убрать, чтобы игроки не могли двигаться

coroutine.wrap(function()
while rootPart.Position:DistanceTo(Planet.Position) <= gravityRange do
humanoid:AddForce(force)
wait(0.1) -- Частота обновления притяжения, можете настроить
end

humanoid.WalkSpeed = 16 -- Возвращаем обычную скорость ходьбы
end)()
end

for _, player in ipairs(game.Players:GetPlayers()) do
attractPlayer(player)
end

game.Players.PlayerAdded:Connect(function(player)
attractPlayer(player)
end)

game.Players.PlayerRemoving:Connect(function(player)
-- Опционально, если хотите остановить притяжение при выходе игрока
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
humanoid.WalkSpeed = 16
end)
Дмитрий ЦарёвУченик (104) 1 неделю назад
спасибооо
Похожие вопросы