Due to FilteringEnabled, i've made a remote event which makes the player talk with the NPC, the owner of tycoon:
-- Server Script inside ServerScriptService
local talk = Instance.new("RemoteEvent", script.Parent["RemoteEvents&Functions"])
talk.Name = "TalkedWithNPC"
talk.OnServerEvent:connect(function(player,a) -- a is the arguments (two arguments)
local Chat = game:GetService("Chat")
local owner = a.Parent.Parent.Tycoon.OwnerShipSystem
if a[2].Name == "OS" then
print(player.Name.." wants ownership")
if owner.Owner.Value == player.Name then
a[2]:ClearallChildren()
local c = Instance.new("Dialogchoice", a[2])
c.Name = "CRa"
c.UserDialog = "Because I'm crazy, man."
c.ResponseDialog = "Oh my god, help me..."
print(player.Name.." is claiming his own ownership")
wait(.5)
Chat:Chat(a[1].Parent.Head,"are you "..player.Name..", right? So, why are you claiming your own ownership?","Green")
elseif game.Players[player.Name].HasanTycoon.Value then
a[2]:ClearallChildren()
local c = Instance.new("Dialogchoice", a[2])
c.Name = "CRa"
c.UserDialog = "Yes, sir..."
c.ResponseDialog = player.Name..", please come back when you get fired... Or anything else."
print(player.Name.." is claiming his own ownership")
wait(.5)
Chat:Chat(a[1].Parent.Head,"Your record isn't empty. "..player.Name..", I don't want you to work for my enemies. Decide, OK?","Green")
elseif owner.Owner.Value == "" then
print(player.Name.." can claim ownership")
wait(.5)
Chat:Chat(a[1].Parent.Head,"Man, you're lucky! We have an empty factory which needs to be filled. are you sure you want to take it?", "Green")
else
print(player.Name.." is unlucky")
a[2]:ClearallChildren()
local c = Instance.new("Dialogchoice", a[2])
c.Name = "CRb"
c.UserDialog = "Who has taken my place?"
c.ResponseDialog = "Don't get mad, guy! The current owner of the factory is "..owner.Owner.Value.."... do you have any problem with that?"
wait(.5)
Chat:Chat(a[1].Parent.Head,"Sorry, but we do not need owners for now. Come back later, please.", "Green")
end
elseif a[2].Name == "Y" then
owner.Owner.Value = player.Name
game.Players:FindFirstChild(owner.Owner.Value).HasanTycoon.Value = true
if game:GetService("MarketplaceService"):PlayerOwnsasset(player, 265421501) then
print("User has gamepass")
a[1].Parent.Parent.Tycoon.Factory.MineralProducer.HasSafetySystem.Value = true
else a[1].Parent.Parent.Tycoon.Factory.MineralProducer.HasSafetySystem.Value = false
end
end
end)
And I tried to fire it with the NPC script:
-- Server Script inside NPC model inside tycoon general model inside workspace
--[[
I tried to run the old script -- which is below, with FilteringEnabled and it didn't work, but no output
]]--
script.Parent.Head.Dialog.DialogChoiceSelected:connect(function(player, choice)
game.ServerScriptService["RemoteEvents&Functions"]:WaitForChild("TalkedWithNPC"):FireServer(script,choice) -- a[1] is this script, a[2] is the choice
end)
But it thrown me an error - yay...
19:33:09.489 - 2 is not a valid member of Script 19:33:09.489 - Script 'ServerScriptService.RemoteGuy', Line 8 19:33:09.489 - Stack End 19:37:43.761 - Auto-Saving... 19:42:43.830 - Auto-Saving...
That error leaves me confused, because the wiki tutorial about it had something like this:
-- Server Script
local event1 = Instance.new("RemoteEvent")
event1.Parent = game.Workspace
event1.Name = "MyServerEvent1"
event1.OnServerEvent:connect(function(player, arguments)
print(player.Name .. " says: " .. arguments)
end)
local event2 = Instance.new("RemoteEvent")
event2.Parent = game.Workspace
event2.Name = "MyServerEvent2"
event2.OnServerEvent:connect(function(player, arguments)
print(player.Name .. " says: " .. arguments[1] .. " " .. arguments[2])
end)
and
-- Inside Local Script
game.Workspace.MyServerEvent1:FireServer("Hello")
game.Workspace.MyServerEvent2:FireServer({"Hello", "World!"})
Can someone tell me what I am doing wrong?
