#RemoteInvoke Problems

163 messages · Page 1 of 1 (latest)

wary thunder
#

like what

jaunty ferry
#

im talking to another guy

#
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Mouse = Player:GetMouse()

local UIS = game:GetService("UserInputService") -- Load button systyem.
local Server = game.ReplicatedStorage.Server -- Looks for the remote function.

local Debounce = false -- Defaults
local Equipped = false
local Chargerr = false

local balls = "Crippled"
local Fireball = game.ReplicatedStorage.Assets.Fireball
UIS.InputBegan:Connect(function(input, GPE)
    if GPE then
        return
    end
    if input.KeyCode == Enum.KeyCode.F and not Chargerr then
Server:InvokeServer("Fireball", "Charge", {})
        Chargerr = true
        local Charge = 0
        local BG = Instance.new("BodyGyro", Character.HumanoidRootPart) --Turning while charging!
        BG.CFrame = CFrame.new(Character.HumanoidRootPart.Position, Mouse.Hit.Position) --Targets mouse.
        BG.MaxTorque = Vector3.one * 99999 --Max force.
        BG.P = 3000 --Power.
        BG.D = 100 --Dammpening.
        BG.Name = "Align" --Named "align" for easy use.

        local BP = Instance.new("BodyPosition", Character.HumanoidRootPart)
        BP.Position = Character.HumanoidRootPart.Position
        BP.MaxForce = Vector3.one * 99999
        BP.P = 3000
        BP.D = 100 --------------------------------Prevents player from moving.
        BP.Name = "Position"
        print(Chargerr)
        repeat
            Charge += 1
            BG.CFrame = CFrame.new(Character.HumanoidRootPart.Position, Mouse.Hit.Position) --Targets mouse.
            task.wait()
        until Chargerr == false 
        Server:InvokeServer("Fireball", "Fire", {Charge = Charge, CFrame = Character.HumanoidRootPart.CFrame,EndPos = Mouse.Hit.Position})
        BG:Destroy()
        BP:Destroy()

    end
end)

UIS.InputEnded:Connect(function(input, GPE)
    if input.KeyCode == Enum.KeyCode.F then
        Chargerr = false
    end
end)
#

First script

#
local Server = game.ReplicatedStorage.Server 
Server.OnServerInvoke = function(Client, Set, Skill, Data)
    Data.Character = Client.Character
    for i, Player in pairs(game.Players:GetPlayers()) do
        if (Player.Character.HumanoidRootPart.Position-Client.Character.HumanoidRootPart.Position).Magnitude < 125 then
            Server:InvokeClient(Player,Set,Skill,Data)

        end
    end
end
#

Server managing thing

wary thunder
#

oh god im not that advanced

jaunty ferry
#
local Server = game.ReplicatedStorage.Server 
local Effects = {}
for i, Module in pairs(script:GetChildren()) do
    Effects[Module.Name] = require(Module)
    Module:Destroy()
end

Server.OnClientInvoke = function(Set,Effect,Data)

    Effects[Set][Effect](Data)
end
#

Replicator

wary thunder
jaunty ferry
#
local module = {}

function module.Charge(Data)
local Character = Data.Character
local Charge = game.ReplicatedStorage.Assets.Fireball.Charge:Clone()
end


return module

module

wary thunder
#

no clue

jaunty ferry
#

Basically the problem is

#

The remotefunction

lost roost
#

JESUS LORD HEAVEN

#

WTF ARE YOU DOING

jaunty ferry
#

yeah

#

Watching a "advanced" video

lost roost
#

THE FUCK

#
Server:InvokeServer("Fireball", "Charge", {})
        Chargerr = true
        local Charge = 0
        local BG = Instance.new("BodyGyro", Character.HumanoidRootPart) --Turning while charging!
        BG.CFrame = CFrame.new(Character.HumanoidRootPart.Position, Mouse.Hit.Position) --Targets mouse.
        BG.MaxTorque = Vector3.one * 99999 --Max force.
        BG.P = 3000 --Power.
        BG.D = 100 --Dammpening.
        BG.Name = "Align" --Named "align" for easy use.

        local BP = Instance.new("BodyPosition", Character.HumanoidRootPart)
        BP.Position = Character.HumanoidRootPart.Position
        BP.MaxForce = Vector3.one * 99999
        BP.P = 3000
        BP.D = 100 --------------------------------Prevents player from moving.
        BP.Name = "Position"
        print(Chargerr)
        repeat
            Charge += 1
            BG.CFrame = CFrame.new(Character.HumanoidRootPart.Position, Mouse.Hit.Position) --Targets mouse.
            task.wait()
        until Chargerr == false 
        Server:InvokeServer("Fireball", "Fire", {Charge = Charge, CFrame = Character.HumanoidRootPart.CFrame,EndPos = Mouse.Hit.Position})
        BG:Destroy()
        BP:Destroy()
#

WHY THE FUCK IS ALL OF THIS HERE!!!

#

all of this is static data!

jaunty ferry
#

💅

lost roost
#

you're redefining it every single time you press the fucking key

#

AHHHHHHHHHHHHHH

#

dies of death

jaunty ferry
#

So

lost roost
#

not the problem, but letting you know you're fucking up badly with that

#

like

#

badly

jaunty ferry
#

uhhh

#

What exactly

lost roost
#

moving on

#

let me see what else

#

I find in this disaster

jaunty ferry
#

"advanced"

#

attempt to index nil with 'Charge'

#

also

#

it outputs this

lost roost
#
local Server = game.ReplicatedStorage.Server 
Server.OnServerInvoke = function(Client, Set, Skill, Data)
     print(Client, Set, Skill, Data)
    Data.Character = Client.Character
    for i, Player in pairs(game.Players:GetPlayers()) do
        if (Player.Character.HumanoidRootPart.Position-Client.Character.HumanoidRootPart.Position).Magnitude < 125 then
            Server:InvokeClient(Player,Set,Skill,Data)

        end
    end
end
jaunty ferry
#

no

lost roost
#
        Server:InvokeServer("Fireball", "Fire", {Charge = Charge, CFrame = Character.HumanoidRootPart.CFrame,EndPos = Mouse.Hit.Position})

this bad

#

you're giving your game to hackers

#

dude, actually burn this shite with fire

#

no wonder roblox games are all fucked up -_-

jaunty ferry
#

I'm still learning

#

🤷‍♂️

lost roost
#

I know I know 😩

#

I just wish there were better resources

#

oh dear

wary thunder
#

can I have help

#

with my gui

lost roost
#

nope, I only have so much time

#

and use

#

your thread

#

not his

wary thunder
#

k

lost roost
#

RUDE

lost roost
#

@jaunty ferry

#

if they are nil the problem is in the client

#

you're sending nil data

#

NO

#
Client.Character.HumanoidRootPart.Position).Magnitude < 125 then
            Server:InvokeClient(Player,Set,Skill,Data)
#

WHAT IS HE DOING

#

NOOOOO

#

ONG

#

Server:InvokeClient(Player,Set,Skill,Data)

#

@latent ledge

#

Dude look at this shit

#

MF LITERALLY CRASHING THE MODULE IF THE PLAYER LEAVESSS

jaunty ferry
#

wait

#

how do you debug

lost roost
#

just print

#

print debug is that

#

I just literally showed you

jaunty ferry
#

prints everything

lost roost
#

print(Client, Set, Skill, Data)

jaunty ferry
#
renars27 Fireball Charge {}
#

output

lost roost
jaunty ferry
#

the

#

replicator

lost roost
#

what's the error 🤔

#

even

jaunty ferry
#
Players.renars27.PlayerScripts.LocalScript:10: attempt to index nil with 'Charge'
lost roost
#

0kay give me the server invoke code

#

with a comment in the error line

#

so I can know

#

🙂

#

line 10

lost roost
#

read what I just sent 😄

jaunty ferry
#

error line comment

lost roost
#

so?

#

are we gonna be here all day 😅

#

cmon

#

I got stuff to do

jaunty ferry
#

i don't understand

lost roost
#

what you mean

#

just send me the server code with a comment in the error line

#

what's so hard about that

#

😅

jaunty ferry
#
local Server = game.ReplicatedStorage.Server 
Server.OnServerInvoke = function(Client, Set, Skill, Data)
    print(Client,Set,Skill,Data)
    Data.Character = Client.Character
    for i, Player in pairs(game.Players:GetPlayers()) do
        if (Player.Character.HumanoidRootPart.Position-Client.Character.HumanoidRootPart.Position).Magnitude < 125 then
            Server:InvokeClient(Player,Set,Skill,Data)

        end
    end --i love big oily men
end

lost roost
#

that's line 10?

#

end --i love big oily men?

jaunty ferry
#

yes

lost roost
#

but you're not indexing charge there

#

are you sure...

jaunty ferry
#

wait

#
local Server = game.ReplicatedStorage.Server 
local Effects = {}
for i, Module in pairs(script:GetChildren()) do
    Effects[Module.Name] = require(Module)
    Module:Destroy()
end

Server.OnClientInvoke = function(Set,Effect,Data)

    Effects[Set][Effect](Data) 
end
#

you mean this script

lost roost
#

I mean whichever script that is giving you the error

#

with a comment in line 10

#

which is were the output marks the error

jaunty ferry
#

yeah this one then

lost roost
#

okay... and which is line 10 🙂

#

I'm not gonna count them

jaunty ferry
#

Effects[] thing

lost roost
#

and what was the error again?

jaunty ferry
#

indexing with nil

lost roost
#

index nil with data?

jaunty ferry
#

attempt to index nil with 'Charge'

lost roost
#

mhm

lost roost
#

it does not exist

#

look in your player Sets data table

#

and make sure it's there

#

that's the error

#

where is that table, Only God knows

#

look for it, add the Set you're asking for

#

and it should work

#

In this case you're sending either Fire or Fireball

#

as the set

#

so yup that

jaunty ferry
#

huh

#
local Server = game.ReplicatedStorage.Server 
Server.OnServerInvoke = function(Client, Set, Skill, Data)
    print(Client,Set,Skill,Data)
    Data.Character = Client.Character
    for i, Player in pairs(game.Players:GetPlayers()) do
        if (Player.Character.HumanoidRootPart.Position-Client.Character.HumanoidRootPart.Position).Magnitude < 125 then
            Server:InvokeClient(Player,Set,Skill,Data)

        end
    end 
end
#

so

#

The set does print when invoked

#

but when it invokes the client

lost roost
#

things to note:

  • This code is very badly designed
  • This code is very unsafe, you're invoking the client and it's also sending you data you could re-design for the server to know alreadty
  • This code is very inneficient, unnecessary loops, and data re-delcaration
  • This code is making request to multiple scripts that are part of the same system, you have TOO MUCH abstraction
lost roost
jaunty ferry
#

OH

lost roost
#

you print what the client is sending you

#

you're not printing the set

#
    Effects[Set][Effect](Data) 

#

this is your set

#

Effects[Set]

#

^ whatever is the key you're using

#

is nil

#

does not exist in the Effects table

lost roost
#

but you should not use this to learn this is absolutely botched

#

but definitely finish the lil project

jaunty ferry
#

Thanks for the help