Sup scripters, im making a mission system and when a player touches the start part then its gonna show a bag via a function i made on a module script, when the player touches the start part it fires the client then it calls the function via the client, then back on the server, it detects the touch of the player of the bag, the problem is that i showed the bag on the client, which the server doesnt detect the bag, then it doesnt work.
I want some of your guys logic to implement that, if i spawn the bag on the server, then everyones gonna see, which is not my goal.
client:
local player = game.Players.LocalPlayer
local playerGui = player.PlayerGui
local startGui = playerGui:WaitForChild("MissionStart")
local endGui = playerGui:WaitForChild("MissionEnd")
local dialogue = playerGui:WaitForChild("Dialogue")
local replicatedStorage = game:GetService("ReplicatedStorage")
local missionLibrary = require(replicatedStorage.Modules.MissionLibrary)
local missionFunctions = require(replicatedStorage.Modules.MissionFunctions)
for _, missionFolder in pairs(replicatedStorage.Missions:GetChildren()) do
if missionFolder.Name == "Test" then
local startEvent = missionFolder.Events.StartMission
local progressEvent = missionFolder.Events.ProgressMission
local endEvent = missionFolder.Events.EndMission
startEvent.OnClientEvent:Connect(function(startClone, bagClone, missionName, missionType)
missionFunctions.Hide(startClone)
missionFunctions.Show(bagClone)
missionFunctions.startGui(startGui, missionName, missionType)
missionFunctions.DialogueControl(dialogue, [[Get the <font color="rgb(255,255,0)">bag</font>.]])
end)
progressEvent.OnClientEvent:Connect(function(bagClone, objectiveClone)
missionFunctions.Hide(bagClone)
missionFunctions.Show(objectiveClone)
missionFunctions.DialogueControl(dialogue, [[Deliver the bag to <font color="rgb(255,255,0)">Lil Pip</font>.]])
end)
end
end
server
local replicatedStorage = game:GetService("ReplicatedStorage")
local missionLibrary = require(replicatedStorage.Modules.MissionLibrary)
local missionFunctions = require(replicatedStorage.Modules.MissionFunctions)
for _, missionFolder in pairs(replicatedStorage.Missions:GetChildren()) do
if missionFolder.Name == "Test" then
local objectsFolder = workspace.Missions[missionFolder.Name]
local startEvent = missionFolder.Events.StartMission
local progressEvent = missionFolder.Events.ProgressMission
local endEvent = missionFolder.Events.EndMission
local missionName = missionLibrary.Missions[missionFolder.Name].Name
local missionType = missionLibrary.Missions[missionFolder.Name].Type
local completedDescription = missionLibrary.Missions[missionFolder.Name].CompletedDescription
local timer = missionLibrary.Missions[missionFolder.Name].Timer
local givesMoney = missionLibrary.Missions[missionFolder.Name].GivesMoney
local givesExperience = missionLibrary.Missions[missionFolder.Name].GivesExperience
local countdown = missionLibrary.Missions[missionFolder.Name].Countdown
local moneyReward = missionLibrary.Missions[missionFolder.Name].MoneyReward
local experienceReward = missionLibrary.Missions[missionFolder.Name].ExperienceReward
local start = missionFolder.Objects.Start
local bag = missionFolder.Objects:WaitForChild("Bag")
local objective = missionFolder.Objects.Objective
local startClone = start:Clone()
local bagClone = bag:Clone()
local objectiveClone = objective:Clone()
startClone.Parent = objectsFolder
bagClone.Parent = objectsFolder
objectiveClone.Parent = objectsFolder
missionFunctions.Hide(bagClone)
missionFunctions.Hide(objectiveClone)
local debounce1 = false
local debounce2 = false
startClone.Touched:Connect(function(hit)
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if player and not debounce1 then
local character = hit.Parent
local missionEnabled = character:WaitForChild("Missions")[missionFolder.Name].Enabled
local missionRunning = character:WaitForChild("Missions")[missionFolder.Name].Running
local missionCompleted = character:WaitForChild("Missions")[missionFolder.Name].Completed
debounce1 = true
if missionEnabled.Value == true then
missionRunning.Value = true
startEvent:FireClient(player, startClone, bagClone, missionName, missionType)
end
wait(5)
debounce1 = false
end
end)
bagClone.Touched:Connect(function(hit)
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if player and not debounce2 then
local character = hit.Parent
local missionEnabled = character:WaitForChild("Missions")[missionFolder.Name].Enabled
local missionRunning = character:WaitForChild("Missions")[missionFolder.Name].Running
local missionCompleted = character:WaitForChild("Missions")[missionFolder.Name].Completed
debounce2 = true
if missionRunning.Value == true then
progressEvent:FireClient(player, bagClone, objectiveClone)
end
wait(5)
debounce2 = false
end
end)
end
end
and sorry for the long script, the part that i want to work is most the bagClone touched event and progress event on client event, thats all!
