So I am making a system for citations in a roleplay group, and I was making sure it all worked. The problem I have been facing is that when I submit the citation, it prints with no answer, except for the player. I have checked, it all seems to line up when it comes to parent.parent, someone help? If you need more pictures just ask me. Thanks so much!
local player = script.Parent.Parent.Parent.Parent.Parent.Name
local Reason = script.Parent.Parent:WaitForChild("Reason").Text
local Citee = script.Parent.Parent:WaitForChild("Citee").Text
local Amount = script.Parent.Parent:WaitForChild("Amount").Text
local Timer = script.Parent.Parent:WaitForChild("Time").Text
local remoteEvent = game.ReplicatedStorage.Citation.CitationSubmitted
script.Parent.Activated:Connect(function()
remoteEvent:FireServer(player, Reason, Citee, Amount, Timer)
end)
local remoteEvent = game.ReplicatedStorage.Citation.CitationSubmitted
local function onCitationFired(player, Reason, Citee, Amount, Timer)
print(player)
print(Reason)
print(Citee)
print(Amount)
print(Timer)
end
remoteEvent.OnServerEvent:Connect(onCitationFired)
remoteevent.OnServerEvent:Connect(function(player, arg)
print(player) -- will print the player who fired it
print(arg)
end)
-- local script
remoteevent:FireServer(arg)
When you fire to a remoteEvent using FireServer the player who fired the event is passed in automatically, if you set it yourself in this case, it assumes that you want to set it to the Reason parameter. You don’t have it in yourself, it does so itself, and the code will still work after removing it and it’ll fix your issues you may be having
For that issue, you just have to change your localscript around, change it to thsi
local frame = script.Parent.Parent
local Reason = frame:WaitForChild("Reason")
local Citee = frame:WaitForChild("Citee")
local Amount = frame:WaitForChild("Amount")
local Timer = frame:WaitForChild("Time")
local remoteEvent = game.ReplicatedStorage.Citation.CitationSubmitted
script.Parent.Activated:Connect(function()
remoteEvent:FireServer(Reason.Text, Citee.Text, Amount.Text, Timer.Text)
end)
Variable to reduce repetition and reference the Text property when you activate the button, it’s probably receiving nil because it immediately gets the text property even if yuo didn’t activate the button