So I have multiple moveset folders which each contain the localscript needed for a moveset. I want to be able to put the a folder that corresponds to the players chosen moveset inside the players character and have it run.
I already have a datastore for keeping track of what moveset the player has.
Basically, what im trying to do is put local scripts in startercharacterscripts but from a server script, but I then learned that you cant do that so, how do I do this?
Are you trying to put specific local scripts inside the character via a server script? Sorry if this sounds likes a dumb question but I don’t quite understand your wording.
He has a datastore that tracks the movesets that the player has. I think he wants to put the moveset that player has selected inside of the their character. Putting them in starterCharacterScripts means that the player would start with every moveset, you could probably disable those movesets though and only enable them when they’re using it.
Couldn’t you just send a table of the moveset data to the client? For instance, you could turn each moveset into a specific number code, then play the entire moveset?
1 is for kick, 2 is for punch, 3 is for dancing or something like that, you could make a table that lists all the movesets, then play it afterward:
{1, 2, 1, 2, 3} is just kick, punch, kick, punch then dance. The client only needs to know which moveset represents which number, then you would play it depending on the moveset data you got. If you want to keep the moveset private, then you might have to pass along extra data about it, modify as you wish though!
This may not be the best design but it should be pretty easy to implement
So on the server side where you handle data, I would set attributes to the player once the data has been loaded, ie
local data = fetchData()
local movesets = data.movesets
for count, moveset in ipairs(movesets) do
player:SetAttribute("moveset" .. count, moveset)
end
then on the client you could have some “movesetLoader”
local movesetScripts = "scriptsLocation"
local function hasDataLoaded()
return player:GetAttribute("moveset1") ~= nil
end
local function onCharacterAdded()
if not hasDataLoaded() then print("no data yet") end
local count = 1;
local currentMoveset = player:GetAttribute("moveset"..count)
while currentMoveset do
local src = movesetScripts:FindFirstChild(currentMoveset)
if not src then
print("could not find moveset script,", src)
break
end
src:Clone().Parent = workspace;
count++;
end
end
-- call onCharacterAdded whenever u know new character has loaded
it doesn’t directly put local scripts in “startercharacterscripts” but I would say it achieves the same goal and is pretty easy to implement some design like this
this does require you to have consistent naming, ie if “punch” is saved as a moveset then you would also need a corresponding script named “punch”