Hello, im not experienced with scripting and im really trying to learn it, but its hard because there are so many errors that dont even make sense, mainly with string values on replicated storage and number values and etc. Im trying to make a reliable mission system and i think im going well, its just a test for a while but when you touch the place where the mission starts, it will copy a screen gui from the mission and paste intos the player’s playergui, and later will detect if the player is in the specified vehicle or not, then change the text based on that, i already fixed most of the errors and now its not getting any errors from the output when you touch the mission blip, simply nothing happens.
Just want to remind that its technically the first time im really trying to script something for myself without seeing tutorials, i really want this to work and if you guys please help me i would be very glad, thanks!
local script
--Variables--
local replicatedStorage = game:GetService("ReplicatedStorage")
--Main Code--
for _, mission in pairs(replicatedStorage.Missions:GetChildren()) do
if mission.Name == "Test" then
local startEvent = mission.Events:WaitForChild("StartMission")
local missionAvaliable = mission.Values:WaitForChild("MissionAvaliable")
local dialogue = mission:WaitForChild("Dialogue")
local state = mission.Values:WaitForChild("MissionState")
local vehicle = mission.Values:WaitForChild("Vehicle")
startEvent.OnClientEvent:Connect(function(player)
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
if missionAvaliable == true then
local objective = dialogue:Clone()
objective.Parent = player:WaitForChild("PlayerGui")
--State Change--
if vehicle.Occupant == nil then
state.Value = "0"
elseif vehicle.Occupant == humanoid then
state.Value = "1"
end
--Dialogue Control--
if state.Value == "0" then
objective.Text = [[Enter the <font color="rgb(0,255,255)">vehicle</font>.]]
elseif state.Value == "1" then
objective.Text = [[Go to the <font color="rgb(255,255,0)">house</font>.]]
end
end
end)
end
end
server script
local replicatedStorage = game:GetService("ReplicatedStorage")
for _, mission in pairs(replicatedStorage.Missions:GetChildren()) do
if mission.Name == "Test" then
local event = mission.Events:WaitForChild("StartMission")
local missionBlip = mission.Values:WaitForChild("MissionBlip")
missionBlip.Value.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
event:FireClient(player)
end
end
end)
end
end