Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Is it possible to fireserver a function through remote event?

So Im trying to get a function to work through remote events because of FE

heres the code

Local Script

UserInput = game:GetService("UserInputService")

  

  

function BigGay()

p = Instance.new("Part")

p.Parent = workspace

end

local remote = game.ReplicatedStorage.RemoteEvent

  

UserInput.InputBegan:Connect(function(input,gameprocessed)

if input.KeyCode == Enum.KeyCode.G then

print('yaa prorooror da')

remote:FireServer(BigGay())

end

end)

And then the script

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player,spawnpart)

spawnpart()

end)

But this keeps erroring 20:33:34.236 - ServerScriptService.local:3: attempt to call local 'spawnpart' (a nil value)

1 comment

0

its not spawnpart() its BigGay()

1 answer

A good idea would be to use remote functions. Here's a example with your code: Client:


local remotefunction = game:GetService("ReplicatedStorage").RemoteFunction
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input,gameProcessedEvent)
	if input.KeyCode == Enum.KeyCode.G and not gameProcessedEvent then
		print("reee")
		remotefunction:InvokeServer()
	end
end)

Server:

local remotefunction = game:GetService("ReplicatedStorage").RemoteFunction
local function BigGay()
	local p = Instance.new("Part")
	p.Parent = workspace
end
remotefunction.OnServerInvoke = BigGay

there you have it, this is a example. Don't copy and paste this and not learn anything from it. This site is meant to teach you, not give you the answers. I used your code and implemented it to make it easier for you to understand. Please read more at: https://developer.roblox.com/articles/Remote-Functions-and-Events

This discussion is preserved as it was. New answers, comments, and votes are closed.