I wouldnt be able to do that with mobs for example, as they are randomly generated, and not preplaced in game
Try giving each mob an ID and associating the ID with the mob you generate. Then check if the mob that was killed has the same questId or whatever as the one in the current step table. When I say an ID for the mob, I don’t mean a single ID for every mob generated but instead a mobId for like a quest mob. Try putting a IntValue in the mob object and making it the index of the step. Then you can check if that IntValue equals the current StoryProgress.
Doing a check on the NPC from the server doesn’t seem to work
local NPC = ExtraData[1]
print(NPC, Story[User.StoryProgress].Objective)
if Story[User.StoryProgress].Objective ~= NPC then return end
print('Complete')
The print returns
Ol’ Mate Ol’ Mate
However, it’s not printing the ‘Complete’
Idk may have something weird to do with replication. Instead of doing NPC = ExtraData[1] could you try NPC = workspace.NPCs[ExtraData[1].Name]?
Think it might have something to do with ExtraData not being set
UpdateStoryProgress:FireServer('Dialogue', NPC.Name)
local function Update(player, event, ...)
local User = PlayerData[player.UserId]
if not User then return end
if Story[User.StoryProgress].Event ~= event then return end -- Make sure the right event is being sent over
local ExtraData = {...}
if event == 'Dialogue' then
print(ExtraData[1]) -- prints nil, should print NPC name
end
end
Are you 100% sure that NPC is not nil?
I really don’t know the problem here. What happens if you do print(game.HttpService:JSONEncode(ExtraData)) on the server?
Ol’ Mate is from the client print.
[] is the JSONEncode
0 is when I do print(#ExtraData)
It shows as empty. Instead of using a variable number of arguments try sending a table that includes the name and name that ExtraData. Maybe that could work I’m not exactly sure why it is happening.
Lets say hypothetically, an exploiter were to fire this many, many many times, and get through the story in an instant like you said, would this impact any other player’s game play experience or give them an advantage above other players? If not, why is there a need to “prevent” this remote event from being abused?
Not entirely sure what you mean?
-- Client
local ExtraData = {Name = NPC.Name}
UpdateStoryProgress:FireServer('Dialogue', ExtraData)
-- Server
local function Update(player, event, extraData)
local User = PlayerData[player.UserId]
if not User then return end
if Story[User.StoryProgress].Event ~= event then return end -- Make sure the right event is being sent over
print(game.HttpService:JSONEncode(extraData))
if event == 'Dialogue' then
print(#extraData)
local NPC = workspace.NPCs:FindFirstChild(extraData[1])
end
end
Still has the same problems
Lets say hypothetically, an exploiter could fire an event that gave them infinite gold. Why would I want that to happen? Same reason why I don’t want them to just cheat their way through the story
This is really, really weird. What happens when you print out NPC.Name on the client? Is it also nil? What type is NPC exactly? A model?
Big ooffa. Turns out I was dumb. NPC is a string already, so doing .Name does nothing. Don’t know why it didn’t error out tho?
But if cheating their way through the story doesn’t make a negative impact on the other players, or doesn’t give them an advantage above other players, which your example you used was an example of having an advantage above other players, I don’t see a reason to prevent them from cheating their way through the story.
Roblox be weird like that some times.
If I’m wanting to prevent exploiters from exploting their way through the story, then it means I have plans to add certain things in the future that would impact other players if you could hack your way to the end
Ok, this seems to work. I think it’s enough checks, should be fine.
local function Update(player, event, ...)
local User = PlayerData[player.UserId]
if not User then return end
if Story[User.StoryProgress].Event ~= event then return end -- Make sure the right event is being sent over
local ExtraData = {...}
if event == 'Dialogue' then
local NPC = workspace.NPCs:FindFirstChild(ExtraData[1])
if not NPC then return end
if Story[User.StoryProgress].Objective ~= NPC then return end
local Character = player.Character
if not Character then return end
local Distance = (NPC.PrimaryPart.CFrame.Position - Character.PrimaryPart.CFrame.Position).magnitude
if Distance > 8 then return end
print('Player is within distance')
User.StoryProgress = User.StoryProgress + 1
end
end
Lua’s default types don’t error if you try to index something that isn’t there. They only error if they can’t be indexed at all (like nil, numbers, etc). Strings can be indexed so you can directly call the string library’s functions on them (e.g. ("somethingamingsomething"):match("gaming")
)