#my abilities are lagging behind and idk why

1 messages · Page 1 of 1 (latest)

obsidian bolt
#

basically when your moving the model spawns a tiny bit behind you idk if its casuse i used uis or because my code is super sloppy but i just need help or a solution im very new

floral lake
#

client != server

#

latency and Roblox desync bs

obsidian bolt
#

so how do i fix it?

floral lake
#

send CFrame from client to server, ez fix

obsidian bolt
#

im new how would i do that?

floral lake
#

🙂

obsidian bolt
#

dude i started last week💔

graceful fog
#

use a module script

obsidian bolt
#

its just a test i didnt know id get this far honestly

graceful fog
graceful fog
#

its far easier

#

and its clean

obsidian bolt
#

idk even know what a module script does man💔

graceful fog
#

its like

#

a way of telling a script "ay bruh, give me the shi u got and lemme use it as mine"

obsidian bolt
#

so can i make like variables for all scripts to ascess?

wild shardBOT
#

studio** You are now Level 3! **studio

graceful fog
#

yes

#

use require(destination of script)

#

you NEED to use require

obsidian bolt
#

i see would this help my delay issue or is it just a tip?

graceful fog
#

as it will not work if u dont

graceful fog
#

the delay is prolly caused by the task.wait

obsidian bolt
#

how would i even migrate my script and how would i set it up even?

graceful fog
#

just copy it all

#

first

floral lake
#

Balls

graceful fog
#

define the module

#

so

#
local module = {} -- < This comes preinstalled in the module itself

function module.HitboxCreation(player: Player)
    -- < Your script here
end)

return module

on the server script u do:

local module = require(modulePath) -- < module path being the place that the module itself is in

Event.OnServerEvent:Connect(function(player)
    module.HitboxCreation(player)
end)
#

this is the process

#

its easy

#

and clean

obsidian bolt
#

so id put this script in the first one?

graceful fog
#

keep that

#

tbh

obsidian bolt
#

okay so what script do i put in the module?

graceful fog
#

i would put a Module in the replicated storage and name it UserInputService

obsidian bolt
#

okay ill do that one sec

#

okay i did it

graceful fog
#

now

#

everthing that has to do with UserInputService

#

put it there

obsidian bolt
#

so the script i sent above?

graceful fog
#

yh

obsidian bolt
#

okay

#

like this?

graceful fog
#

i would suggest using a module. something you would use across all the scripts

#

so

#

lemme pull up my studio

obsidian bolt
#

dude tysm i just get insulted for not knowing stuff your deadass so helpful

graceful fog
#

anytime

floral lake
#

Is smiling an insult now

obsidian bolt
#

im not talking abt you ive met other people here

floral lake
#

understandable

graceful fog
#

the script should look something like

#

the code to copy:

#

local ReplicatedStorage = game:GetService("ReplicatedStorage")
for i, v in ReplicatedStorage:GetDescendants() do
if v:IsA("ModuleScript") then
require(v)
end
end

#

the module should look something like

#
-- // Service's
local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(Input, gameProcessed)
    if gameProcessed then return end

    if Input then
        
    end
end)

return {}
#

now u can check what input is being used

#

you need to keep the return {}

obsidian bolt
#

so i add that indo my module?

graceful fog
#

give me ur module script

#

copy its code

obsidian bolt
#

local module = {} -- < This comes preinstalled in the module itself

function module.HitboxCreation(player: Player)
local uis = game:GetService("UserInputService")
local replicatedstorage = game:GetService("ReplicatedStorage")
local event = replicatedstorage.remotes.attack
local player = game.Players.LocalPlayer

uis.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.Z then
        local character = player.Character
        if character and character:FindFirstChild("HumanoidRootPart") then
            character.HumanoidRootPart.Anchored = true
        end
        event:FireServer()
        print("fired")
    end
end)

end

return module

graceful fog
#

brb

obsidian bolt
#

oaky

graceful fog
#

wait

#

lemme tweak it rq

#
-- // Service's
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

-- // Variables
local Event = ReplicatedStorage.remotes.attack
local player = game.Players.LocalPlayer

UserInputService.InputBegan:Connect(function(input, gameProcessedEvent: boolean)
    if gameProcessedEvent then return end

    if input.KeyCode == Enum.KeyCode.Z then
        local character = player.Character
        if character and character:FindFirstChild("HumanoidRootPart") then
            character.HumanoidRootPart.Anchored = true
        end
        Event:FireServer()
        print("fired")
    end
end)


return {}
#

use this

obsidian bolt
#

okay i added it

graceful fog
#

bet

obsidian bolt
#

so do i need to tweak my other script?

graceful fog
#

just copy mine and paste it in urs

obsidian bolt
#

okay

#

local ReplicatedStorage = game:GetService("ReplicatedStorage")
for i, v in ReplicatedStorage:GetDescendants() do
if v:IsA("ModuleScript") then
require(v)
end
end

#

so with this script is it already added or do i haev to add it somewhere?

graceful fog
obsidian bolt
#

okay i added it there

#

idk if we are done but i tested it and the delay is still there i was walking forward and im supposed to be in the middle

obsidian bolt
#

so just weld it to the humanoidrootpart?

graceful fog
#

yh

obsidian bolt
#

if your still awake i took a break but how do you like get acsess to the variables in other scripts like you said you could do?

obsidian bolt
#

the ones here

#

in the module

graceful fog
#

you put the stuff u want to return in the table

wild shardBOT
#

studio** You are now Level 8! **studio

graceful fog
#

and do

#
local result = moduleYouUse
print(result)
obsidian bolt
#

so i put the variables i want to use in other scripts in the return table?

wild shardBOT
#

studio** You are now Level 4! **studio