Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

The scripts in the map won't work when I clone it into workspace, is there a way to fix this?

Asked by 4 years ago
Edited 4 years ago

I used a RemoteEvent to clone the map into workspace but the scripts don't work when I clone it into workspace. I'm only cloning the map for one player, not all of the players.

Here is the normal script in the workspace inside a part:

workspace.Entrance:WaitForChild("Part01").Touched:Connect(function(hit)
   if hit.Parent:FindFirstChild("Humanoid", 10) then
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
            game:GetService("ReplicatedStorage").REs.LoadMap:FireClient(plr)
           wait(1)
        hit.Parent.HumanoidRootPart.CFrame = CFrame.new(-106.643, 11.077, -1065.204)
        wait(0.2)
        hit.Parent.LocalScript.Disabled = false
        hit.Parent.BackCamRemoval.Disabled = false
        workspace["Crickets"]:Play()
        workspace["Music"]:Play()
        plr.InGame.Value = true
        hit.Parent.ScoreEnabled.Value = true
        plr.PlayerGui.Results:WaitForChild("Stats"):WaitForChild("Timer").Time.Disabled = false

            for i,v in pairs(workspace.Door.Base:GetChildren()) do
       if v:IsA("Part") then
            v.Transparency = 0
            v.CanCollide = true
        end

    end

    workspace.Door.Base.CanCollide = true
    workspace.Door.Base.Transparency = 0

    for i,v in pairs(workspace.Door.BaseOpen:GetChildren()) do
        if v:IsA("Part") then
            v.Transparency = 1
            v.CanCollide = false
        end
    end

    workspace.Door.BaseOpen.Transparency = 1
    workspace.Door.Base["Door_Close02 (Source)"]:Play()

    workspace.Entrance.Part01.Transparency = 1
    workspace.Entrance.Part02.Transparency = 1
    workspace.Entrance.Part03.Transparency = 1
    workspace.Entrance.Part04.Transparency = 1
    workspace.Entrance.Part05.Transparency = 1
    workspace.Entrance.Players.Value = 1
    end
    --]]
end)

Here is the local script in the StarterGui:

game:GetService("ReplicatedStorage").REs.LoadMap.OnClientEvent:Connect(function(plr)
    if not workspace:FindFirstChild("CityMap") then 
      game.ReplicatedStorage.CityAssets.CityMap:Clone().Parent = workspace
    end
end)
0
The normal script isn't working because it runs on the server side. Cloning a map on the client side only creates the map for the client, and not the server. Since the server can't see it, the server can't do anything with it. Rinpix 639 — 4y
0
So do I have to make it multiplayer? User#26978 0 — 4y

Answer this question