How to set mas speed for my marble system? So i have marble system. I cant figure out how to make max speed for it
here are the scripts:
StarterCharacterScripts (Client )
local TweenService = game:GetService("TweenService") local UIS = game:GetService("UserInputService") local L = game:GetService("Lighting") local RunService = game:GetService("RunService") local MasterControl = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"):WaitForChild("ControlModule")) local Player = game.Players.LocalPlayer local Character = script.Parent.Parent local HRP = Character:WaitForChild("HumanoidRootPart") local Humanoid = Character:WaitForChild("Humanoid") local PlayerGui = Player:WaitForChild("PlayerGui") local MarketplaceService = game:GetService("MarketplaceService") local MainGUI = PlayerGui:WaitForChild("Main") local SpeedTxt = MainGUI:WaitForChild("Speed") local RefreshGamepass = script.Parent:WaitForChild("RefreshGamepass") local Vap = workspace:WaitForChild("Vap") local Flange = Vap:WaitForChild("Flange") local Blur = L:WaitForChild("Blur") local Camera = workspace.CurrentCamera local Remote = script.Parent:WaitForChild("Remote") --//SETTINGS\\-- local Speed = 3 local JumpPower = 75 ---------------- --//VARIABLES\\-- local xDelta = 0 local zDelta = 0 local Colliding = false local NormalVector = HRP.CFrame.upVector ----------------- function CheckGamePass() local HasPass = false local success, message = pcall(function() HasPass = MarketplaceService:UserOwnsGamePassAsync(Player.userId, 6898178) if HasPass == true then Speed = 6 end end) end CheckGamePass() RefreshGamepass.Event:Connect(CheckGamePass) local Ball = Character:WaitForChild("Ball") local Rolling = Ball:WaitForChild("Rolling") Camera.CameraSubject = Ball UIS.JumpRequest:Connect(function() if Colliding == true then Ball.Velocity = Ball.Velocity + NormalVector*JumpPower end end) function floatFormat(v) return tonumber(string.format(2 and "%.".. 2 .."f" or "%f",v):reverse():match("^0*%.?(.+)$"):reverse()) end while RunService.RenderStepped:Wait()do local ray = Ray.new(Ball.Position,CFrame.new(Ball.Position,Ball.Position-Vector3.new(0,2,0)).lookVector*6) local hit,pos,normal = workspace:FindPartOnRayWithIgnoreList(ray,{Character}) if hit ~= nil and hit.CanCollide == true and Ball.CanCollide == true then NormalVector = normal Colliding = true if Rolling.Playing == false then Remote:FireServer("PlayRolling") end else Colliding = false if Rolling.Playing == true then Remote:FireServer("StopRolling") end end local mag = Ball.Velocity.magnitude/10 SpeedTxt.Text = math.floor(Ball.Velocity.magnitude) if mag > 2 then if mag > 50 then mag = 50 end TweenService:Create(Camera,TweenInfo.new(.1),{FieldOfView = 70+mag}):Play() TweenService:Create(Flange,TweenInfo.new(.1),{Mix = (mag*2)/100}):Play() TweenService:Create(Blur,TweenInfo.new(.1),{Size = 6+(3*(mag/0))}):Play() else if Camera.FieldOfView ~= 70 then TweenService:Create(Camera,TweenInfo.new(1),{FieldOfView = 70}):Play() TweenService:Create(Flange,TweenInfo.new(1),{Mix = 0}):Play() TweenService:Create(Blur,TweenInfo.new(1),{Size = 0}):Play() end end local move = MasterControl:GetMoveVector() local xDelta = floatFormat(move.x) local zDelta = floatFormat(move.z) if ((xDelta ~= 0) or (zDelta ~= 0)) and Ball.CanCollide == true then local MoveDir = CFrame.new(Camera.CFrame.Position, (Camera.CFrame * CFrame.new(xDelta, 0, zDelta)).Position) local OldY = Ball.Velocity.Y local BallVel = Ball.Velocity + (MoveDir.lookVector * Speed) Ball.Velocity = Vector3.new(BallVel.X,OldY,BallVel.Z) end end
StarterCharacterScripts (Server)
local Character = script.Parent.Parent local Player = game.Players:GetPlayerFromCharacter(Character) local HRP = Character:WaitForChild("HumanoidRootPart") local Humanoid = Character:WaitForChild("Humanoid") Humanoid.PlatformStand = true Character:SetPrimaryPartCFrame(HRP.CFrame*CFrame.new(0,5,0)) local Ball = script:WaitForChild("Ball") local Rolling = Ball:WaitForChild("Rolling") local Remote = script.Parent:WaitForChild("Remote") function Weld(x,y) local W = Instance.new("Weld") W.Part0 = x W.Part1 = y local CJ = CFrame.new(x.Position) local C0 = x.CFrame:inverse()*CJ local C1 = y.CFrame:inverse()*CJ W.C0 = C0 W.C1 = C1 W.Parent = x end Ball:SetNetworkOwner(Player) Ball.CFrame = HRP.CFrame Ball.Parent = Character Weld(Ball,HRP) Rolling:Play() script.Parent:WaitForChild("Client").Disabled = false Remote.OnServerEvent:Connect(function(vPlayer,request,var) if vPlayer ~= Player then vPlayer:Kick("Unauthorized signal");end if request == "PlayRolling" and Rolling.IsPlaying == false then Rolling:Play() elseif request == "StopRolling" and Rolling.IsPlaying == true then Rolling:Stop() end end) while wait(.1)do local Speed = 30 + (Ball.Velocity.magnitude/20) if Speed > 60 then Speed = 60;end Rolling.PlaybackSpeed = Speed local Vol = (Ball.Velocity.magnitude/20) if Vol > 5 then Vol = 5;end Rolling.Volume = Vol end script.Ball.Velocity.MaxTorque = Vector3.new(60,60,60)