I’m making a GUI that allows the character to morph into a custom character, but I can’t figure out how to make the local script reference something in server storage to the server
please feel free to ask me to rephrase, if i wrote it confusingly!
here is the local script
rs = game:GetService("ReplicatedStorage")
rme = rs.changeModel
f = script.Parent
--//-
f.plrBuilder.MouseButton1Click:Connect(function()
local wantedChar = game:GetService("ServerStorage").PlayerEnemies.CharacterBuilder --I realize that you can't access serverstorage from a local script
rme:FireServer(wantedChar)
end)
f.plrAdmin.MouseButton1Click:Connect(function()
local wantedChar = game:GetService("ServerStorage").PlayerEnemies.AdminOnly
rme:FireServer(wantedChar)
end)
and here is the server script
pe = game:GetService("ServerStorage"):WaitForChild("PlayerEnemies")
game.ReplicatedStorage.changeModel.OnServerEvent:Connect(function(player, wantedChar)
local oldChar = player.Character
local newChar = wantedChar:Clone()
newChar.HumanoidRootPart.Anchored = false
newChar:SetPrimaryPartCFrame(oldChar.PrimaryPart.CFrame)
player.Character = newChar
newChar.Parent = workspace
end)
If there are better methods of going about making a morph gui entirely, I’d also like to hear that! Thank you in advance.
pe = game:GetService("ServerStorage"):WaitForChild("PlayerEnemies")
game.ReplicatedStorage.changeModel.OnServerEvent:Connect(function(player, CharName)
local wantedChar = pe:FindFirstChild(CharName)
if not wantedChar then return end
local oldChar = player.Character
local newChar = wantedChar:Clone()
newChar.HumanoidRootPart.Anchored = false
newChar:SetPrimaryPartCFrame(oldChar.PrimaryPart.CFrame)
player.Character = newChar
newChar.Parent = workspace
end)