What do you want to achieve?
i want the main script to check if the text is the same as the one in the module script after the player has clicked a TextButton
What is the issue?
I’ve genuinely have got 0 clue how to
What solutions have you tried so far?
I’ve tried many, but I’m not sure how to say them
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ActionEvent = ReplicatedStorage.ActionEvent
local Module = require(game.ServerScriptService.ActionHandler.Information)
ActionEvent.OnServerEvent:Connect(function(player, text)
end)
Local script (where it’s fired from)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ActionEvent = ReplicatedStorage.ActionEvent
script.Parent.MouseButton1Down:Connect(function(text)
ActionEvent:FireServer("Jump")
end)
Here is a picture of how everything is organized
do note that I don’t want to make a replicatedEvent for every action, since I will most likely have a lot more than 3 actions
19:38:28.278 ServerScriptService.ActionHandler:7: attempt to index nil with 'Animation' - Server - ActionHandler:7
is this because you can’t print it or is there another issue?
(tried it with Price aswell, since I assumed that you can’t print the animation ID, but it didn’t work either.)
when I tried the script you provided originally it threw me out an error
Network is not a valid member of ReplicatedStorage "ReplicatedStorage" - Server - ActionHandler:12
your provided version
main
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ActionEvent = ReplicatedStorage.ActionEvent
local Module = require(game.ServerScriptService.ActionHandler.Information)
game:GetService("ReplicatedStorage").Network.Test.OnServerEvent:Connect(function(player,text)
print(Module[text].HeheTest)
end)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ActionEvent = ReplicatedStorage.ActionEvent
local Actions = require(game.ServerScriptService.ActionHandler.Information)
ActionEvent.OnServerEvent:Connect(function(player, text)
if Actions[text] == nil then
print("Doesn't exist in actions module")
else
print("Action is valid...")
print(Actions[text].RespondingText)
end
end)
now it depends on what you are trying to achieve but if something
20:01:49.808 Jump - Server - ActionHandler:13
20:01:49.808 ServerScriptService.ActionHandler:14: attempt to index nil with 'RespondingText' - Server - ActionHandler:14
anyways, @iFlameyz fixed the issue for me
I do want to thank you for helping me <3 I really appreciate it
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ActionEvent = ReplicatedStorage.ActionEvent
local Module = require(game.ServerScriptService.ActionHandler.Information)
ActionEvent.OnServerEvent:Connect(function(player, text)
for _, v in next, Module do
if v.Name == text then
-- your code here :)
end
end
end)
Or alternatively you could do
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ActionEvent = ReplicatedStorage.ActionEvent
local Module = require(game.ServerScriptService.ActionHandler.Information)
ActionEvent.OnServerEvent:Connect(function(player, text)
for k, _ in next, Module do
if k == text then
-- your code here :)
end
end
end)
If you did the second one you wouldn’t need to modify the module script
The script would error without the if check if the remote sent something else + trying to keep it as short and simple with prints to help sipo understand it or any person that might come across this post