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

Why does this script execute one "step" behind?

Asked by
Uglypoe 557 Donator Moderation Voter
9 years ago

For some reason, my script always executes these "steps" one step behind on Mobile devices. And idea on why this might be happening? I posted relevant coding below. Thanks!

repeat wait() until game.Players.LocalPlayer.Character ~= nil
wait()
currentcell = game.ReplicatedStorage.Move:InvokeServer()
mouse = game.Players.LocalPlayer:GetMouse()

active = false
moving = false
run = false
keyboard = false
touch = false
if game:GetService("UserInputService").KeyboardEnabled == true then
keyboard = true
else
if game:GetService("UserInputService").TouchEnabled == true then
touch = true
end end

if keyboard then
--things
else
if touch then
game:GetService("UserInputService").TouchStarted:connect(function()
if active == false and mouse.Hit and ((mouse.Hit.p-currentcell.PrimaryPart.Position).magnitude <= 15 and (mouse.Hit.p-currentcell.PrimaryPart.Position).magnitude >= 5) then
active = true
local mouspos = mouse.Hit.p
local ray = Ray.new(currentcell.PrimaryPart.Position,((mouspos-currentcell.PrimaryPart.Position).unit*10)*Vector3.new(1,0,1))
local part = game.Workspace:FindPartOnRayWithIgnoreList(ray,{game.Players.LocalPlayer.Character,currentcell})
if part ~= nil and part.Parent ~= nil and part.Parent.Name == "FloorCell" and (currentcell.PrimaryPart.Position-part.Parent.PrimaryPart.Position).magnitude == 10 then
currentcell = part.Parent
moving = true
game.Players.LocalPlayer.Character.Humanoid:MoveTo(Vector3.new(part.Position.X,part.Position.Y+5,part.Position.Z))
end
if moving == true then
game.Players.LocalPlayer.Character.Humanoid.MoveToFinished:connect(function()
game.Players.LocalPlayer.Character.Torso.Velocity = Vector3.new(0,0,0)
moving = false
active = false
end)
else
active = false
end end end) end end
0
Possible lag on a mobile device? Maybe lua needs a really good cpu to exectute at the right time? Just chucking ideas out. TheDeadlyPanther 2460 — 9y
0
I don't think it's that. It's like when you click on one spot to move to when you first join, it doesn't work. When you click on a second spot, you'll go to the first spot. Third click to second spot. etc. Uglypoe 557 — 9y

Answer this question