Script copied from replicated storage doesnt work when cloned?

Hey guys, in these scripts I am trying to copy a LocalScript from a folder in ReplicatedStorage into a certain objective brick whenever I click a gui. The script to put the cloned script into an objective works, but the cloned script doesnt actually function.

I’ve tried a bunch of different things and looked at the forums but couldnt find anything I could use.

Any help is appreciated

Script from gui (on button press to accept)

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteevent = ReplicatedStorage.Delivery



In the serverscript from the remote event

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteevent = ReplicatedStorage.Delivery
local GUI =  ReplicatedStorage.DeliveryGUI
local AddScript = GUI.AddedScript:Clone()
local objectives = game.Workspace.Objectives

remoteevent.OnServerEvent:Connect(function(player, localplayer)

	local ObjectiveChosen = math.random(1,5)
	if ObjectiveChosen == 1 then
		print("objective 1")
		AddScript.Parent = objectives.Objective1
	elseif ObjectiveChosen == 2 then
		print("objective 2")
		AddScript.Parent = objectives.Objective2
	elseif ObjectiveChosen == 3 then
		print("objective 3")
		AddScript.Parent = objectives.Objective3
	elseif ObjectiveChosen == 4 then
		print("objective 4")
		AddScript.Parent = objectives.Objective4
	elseif ObjectiveChosen == 5 then
		print("objective 5")
		AddScript.Parent = objectives.Objective5

I might be misunderstanding but it sounds like you put a local script as a descendant of workspace. Local scripts won’t run there. You’ll have to put a normal script with a run context set to client for that to work.

I double checked to make the sure all the scripts were being put into the object.

(the script is a Script.Parent.Touched type script)


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.