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

How would i fire some properties of a remote event including the player object to a server script?

e.g: i have a local script that fires a remote event which takes the properties of what i listed in the brackets, and for some reason when i fire it the server script that handles it gives me an error. Here are my scripts:

Local:

script.Parent.Enabled = true
local forcePlayRemote = game.ReplicatedStorage.DevCommandEvents.ForcePlay
local plr = game.Players.LocalPlayer
local plrName = plr.Name
local changeValueRemote = game.ReplicatedStorage.ChangePlrValue
local char = plr.Character or plr.CharacterAdded:Wait()
changeValueRemote:FireServer(char,"InLobby",true)
local tweenService = game:GetService("TweenService")
local crouchGUI = script.Parent.Parent.Crouch
local vals = game.ReplicatedStorage.Vals
local gameValue = vals.GameInProgress
local fade = script.Parent.Parent.Fade.Frame
local frame = script.Parent.Frame
local playBtn = frame.PlayBtn
local cameraPart1 = game.Workspace.Intro.Cam1
local cameraPart2 = game.Workspace.Intro.Cam2
local camera = workspace.CurrentCamera
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local goal = {}
goal.CFrame = cameraPart2.CFrame
local goal2 = {}
goal2.BackgroundTransparency = 0
local goal3 = {}
goal3.BackgroundTransparency = 1

local tween = tweenService:Create(camera, tweenInfo, goal)

local tween2 = tweenService:Create(fade, tweenInfo, goal2)

local tween3 = tweenService:Create(fade, tweenInfo, goal3)

repeat wait()
	camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType == Enum.CameraType.Scriptable

camera.CFrame = cameraPart1.CFrame

playBtn.MouseButton1Click:Connect(function()
	changeValueRemote:FireServer(char,"InLobby",false)
	frame:TweenPosition(UDim2.new(0, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quint, 1)
	tween:Play()
	tween.Completed:Wait()
	wait(1)
	tween2:Play()
	tween2.Completed:Wait()
	camera.CameraSubject = char:WaitForChild("Humanoid")
	camera.CameraType = Enum.CameraType.Custom
	wait(1)
	tween3:Play()
	if gameValue.Value == true then
		crouchGUI.Enabled = true
	else
		crouchGUI.Enabled = false
	end
end)

forcePlayRemote.OnClientEvent:Connect(function()
	changeValueRemote:FireServer(char,"InLobby",false)
	frame:TweenPosition(UDim2.new(0, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quint, 1)
	tween:Play()
	tween.Completed:Wait()
	wait(1)
	tween2:Play()
	tween2.Completed:Wait()
	camera.CameraSubject = char:WaitForChild("Humanoid")
	camera.CameraType = Enum.CameraType.Custom
	wait(1)
	tween3:Play()
	if gameValue.Value == true then
		crouchGUI.Enabled = true
	else
		crouchGUI.Enabled = false
	end
end)

Server:

local remoteEvents = {game.ReplicatedStorage.ChangePlrValue}

remoteEvents[1].OnServerEvent:Connect(function(char,valueName,value)
	local plr = game.Players:GetPlayerFromCharacter(char)
	plr:WaitForChild(valueName).Value = value
end)

Please contact me ASAP if more info is needed, you can do that by commenting (recommended because i'm not really active on discord), or DM ing me on discord at: @Dexiber #7008

1 answer

✓ Accepted answer

When you fire to the server, Player is a default.

LocalScript:

local Arg1 = nil
local Arg2 = nil

game.ReplicatedStorage.RemoteEvent:FireServer(Arg1, Arg2)

ServerScript:

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(Player, Arg1, Arg2)
	--script here
end)

With remote events to fire to the server, I found that if you do not pass through the player like I did above it can become hard to pass through values.

Best regards, Detective.

1 comment

0

You are a very cool person, Thanks.

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