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
script.Parent.MouseButton1Down:Connect(function()
script.Parent.Parent.Parent:Destroy()
remoteevent:FireServer(game.Players.LocalPlayer)
end)
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)
task.wait(0.1)
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
end
print("done")
end)