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

why is this remote event not sending parameters properly and mixing them up?

local player = game.Players.LocalPlayer
local reloadAnim = tool.Animations.R6GlockReload
local reloadSound = tool.Animations.ReloadSound
local reloadEvent = local reloadEvent = replicatedstorage.glockEvents.ReloadEvent

function reload()
	if ammo.Value ~= ammoCapacityStat then 
	local ammoToTake = ammoCapacityStat - ammo.Value
		if reserveAmmo.Value <= 0 then 
			print("no reserve")
			else
			if reloading == false then
				reloading = true
				reloadEvent:FireServer(player,reloadAnim,reloadSound)

Hey guys im trying to send this data to a server script to play a reload animation and reload sound from the server

replicatedStorage.glockEvents.ReloadEvent.OnServerEvent:Connect(function(player,reloadAnim,reloadSound) 
		print (player)
		print (reloadAnim)
		print (reloadSound)

However when this second script outputs instead of outputting like this as i would expect:

StarDestroy, R6GlockReload, ReloadSound

it outputs like this instead

StarDestroy, StarDestroy, R6GlockReload

To me it seems like the script is mixing up the parameters and i don't understand why. I even have this same setup in another part of my script and it works fine. How can i solve this?

1 answer

✓ Accepted answer

When you use FireServer from user client, it also sends the Player instance to the server as a case to determine which player's client the request is from. That said, you don't need to pass the player instance manually through FireServer, only reloadAnim and reloadSound are enough!

reloadEvent:FireServer(reloadAnim,reloadSound)

The last script is totally correct. Its first argument always return the player instance. Same goes for RemoteFunctions in the same scenario.

I hope this explains it all! Good luck! c:

2 comments

1

ah that makes sense thanks man

0

no probss!

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