#problem with adding localscripts to the player and changing camera

1 messages · Page 1 of 1 (latest)

static oxide
#

--serverscript
local table = {
[1] = "Cowboi",
[2] = "Swordboi"
}
local replicatedstorage = game:GetService("ReplicatedStorage")
local event = game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("ChooseEvent")
event.OnServerEvent:Connect(function(player:Player,scripts, page:IntValue, camera)
local char = player.Character
local charname = table[page.Value]
local boiscripts = replicatedstorage.CharacterScripts:FindFirstChild(charname.."Scripts")
local movementscripts = replicatedstorage.MovementScripts
local character = replicatedstorage.Characters:FindFirstChild(charname)
char:Destroy()
local newchar = character:Clone()
newchar.Name = player.Name
newchar.Parent = workspace
player.Character = newchar
player.Character:PivotTo(workspace:FindFirstChild("spawn here").CFrame)
local hrt = newchar:FindFirstChild("HumanoidRootPart")
event:FireClient(player, hrt)
for _, locscript in pairs(boiscripts:GetChildren()) do
local newscript = locscript:Clone()
newscript.Parent = scripts
--newscript.Enabled = true
end
for _, locscript in pairs(movementscripts:GetChildren()) do
local newscript = locscript:Clone()
newscript.Parent = scripts
--newscript.Enabled = true
end
end) it causes no errors in output btw

And also it deletes the gui and then it immediately reappears i know its cuz ResetOnSpawn but even when i disable it in server script or local it still reappears..?

#

Local:

#

local event = game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("ChooseEvent") local camera:Camera = workspace.CurrentCamera local player = game.Players.LocalPlayer local gui = script.Parent.Parent.Parent local page = script.Parent.Parent.Page local scripts:PlayerScripts = player:WaitForChild("PlayerScripts") script.Parent.MouseButton1Click:Connect(function() event:FireServer(scripts, page, camera) gui:Destroy() end) event.OnClientEvent:Connect(function(hrt) camera.CameraSubject = hrt end)

modern torrent
#

You can’t clone LocalScripts from the server into the client and expect them to run.
Even though you’re technically cloning to the PlayerScripts folder, since only the client can run LocalScripts, they must be cloned from the client side or placed in StarterPlayerScripts / StarterCharacterScripts ahead of time.

#

NO OFFENSE

#

i could be looking at this wrong

#

and for the gui...

#

i need to ponder

plucky wadi
#
local table = {
    [1] = "Cowboi",
    [2] = "Swordboi"
}
local replicatedstorage = game:GetService("ReplicatedStorage")
local event = game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("ChooseEvent")
event.OnServerEvent:Connect(function(player:Player,scripts, page:IntValue, camera) 
    local char = player.Character
    local charname = table[page.Value]
    local boiscripts = replicatedstorage.CharacterScripts:FindFirstChild(charname.."Scripts")
    local movementscripts = replicatedstorage.MovementScripts
    local character = replicatedstorage.Characters:FindFirstChild(charname)
    char:Destroy()
    local newchar = character:Clone()
    newchar.Name = player.Name
    newchar.Parent = workspace
    player.Character = newchar
    player.Character:PivotTo(workspace:FindFirstChild("spawn here").CFrame)
    local hrt = newchar:FindFirstChild("HumanoidRootPart")
    event:FireClient(player, hrt)
    for _, locscript in pairs(boiscripts:GetChildren()) do
        local newscript = locscript:Clone()
        newscript.Parent = scripts
        --newscript.Enabled = true
    end
    for _, locscript in pairs(movementscripts:GetChildren()) do
        local newscript = locscript:Clone()
        newscript.Parent = scripts
        --newscript.Enabled = true
    end
end) 
#

yeah you cant just enable or disable a script and have it work

#

it needs to already be there enabled

modern torrent
#

ohhh shoot

#

If the server clones them into PlayerScripts, they just sit there dead, even if .Enabled = true. So what you’re seeing (scripts not activating) is totally expected behavior

static oxide