#Task.Synchronize strange behavior

1 messages · Page 1 of 1 (latest)

night prairie
#

When requiring a module (that has already been required by another script) within my NPC Acotr, the module code runs again.

Location of the module (PunchServer) game.ServerStorage.PunchServer

Attached below are the screenshots of the code that throws the error:

Parenting MeleeRemotes to ReplicatedStorage is just some initialization code I have.

#

@harsh vale @winter vault

#

@harsh vale Do you want to know where the module PunchServer is?

harsh vale
#

add this print to see where the script is

print(script:GetFullName())
local MeleeRemotes = script.MeleeRemotes
night prairie
#

or the NPC actor

#

Image with task.Synchronize is located in workspace.NPC.NPCActor

harsh vale
#

send me a screenshot of the print

night prairie
#

Running in NPCServerScript

night prairie
#

ServerStorage.PunchServer (x2)

#

it's running twice

winter vault
#

are those client scripts LocalScript instaces or a Script with the RunContext set to Client?

#

It might be that those scripts are running in the StarterPlayer and the player's character so that's why it runs twice

night prairie
#

those scripts dont run anything

#

just print("Hello world")

winter vault
#

ok yeah so that' why, you need to put a check and see if the parent of the actor's parent is StarterCharacter, if so then don't run any code

winter vault
#
if not script:FindFirstAncestorOfClass("StarterCharacterScripts") then
    -- Run code --
end
night prairie
#

its an NPC in workspace

#

just named "StarterCharacter"

winter vault
#

oh

night prairie
#

Anyway LMK if you guys know why this may be the case

#

One of my friends told me that apparently you are supposed to feed the module data into the actor via a bindable event

#

but that sounds like a whole lotta work that I don't feel like adding

winter vault
#

yeah, might be because you're requiring the module from outside the actor

#

try moving the module inside the actor and see if it still happens

harsh vale
night prairie
night prairie
winter vault
harsh vale
#

screenshot of explorer

night prairie
#

Transfers assets on server startup

#

to rep storage, etc

winter vault
#

says here that all instances used by scripts should be under the same actor

night prairie
#

also @harsh vale I do have some remote event listener connections in PunchServer, but that shouldn't be a problem I believe

winter vault
#

you can use these functions for cross communication between actors

night prairie
#

it's mainly just so I can use the punch functions without having to paste code everywhere

lapis wolf
#

@night prairie what font do u use?

night prairie