Am I using RemoteEvent properly?

I’m currently trying to make a script where once a player carries a car, a part will become transparent and allow them to see under it. I’m using RemoteEvent, however, to only allow the player carrying the car to see under. But after some research and tutorials, I just can’t figure out how to make the local script which should fire the function to the client only to work. Here are both scripts–

Server Script:

local anim = script.Animation
local Car = script.Parent.Parent.Car

local debounce = nil

script.Parent.Touched:Connect(function(hit)
	print(hit)
	local Car2 = Car:Clone()
	Car2.Parent = Car.Parent
	local humanoid = hit.Parent.Humanoid
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	local animTrack = humanoid:LoadAnimation(anim)
	local re = game:GetService("ReplicatedStorage")
	local Film = script.Parent.Parent:FindFirstChild("Film")
	
--code to make the player carry car
	
	if humanoid then
		re.RemoteEvent:FireClient(player, Film)
	end

end)

Local script (located in StarterPlayerScripts)

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local PartsIncluded = ReplicatedStorage:WaitForChild("RemoteEvent")

local function Show(player, Film)
	print(Film)
	Film.Transparency = 1
end

PartsIncluded.OnClientEvent:Connect(function()
	Show()
end)
local function Show(Film)
	print(Film)
	Film.Transparency = 1
end

PartsIncluded.OnClientEvent:Connect(Show)

That should work.

PartsIncluded.OnClientEvent:Connect(function(Film)
	print(Film)
	Film.Transparency = 1
end)

This would also work.


OnClientEvent doesn’t take a player argument, as well as in your original code, you didn’t pass the arguments through the Show function, so the function had nothing to work with.

Thanks for the simple solution! Glad to know I wasn’t that far off.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.