So I'm trying to make a material changer, so if I click on my left mouse button, it will change the material, it can work on localscript but CAN'T work when I try to covert it too FE compatible
here is if it's not FE :
local mouse = game:GetService("Players").LocalPlayer:GetMouse() mouse.Button1Down:Connect(function() if mouse.Target.Name ~= "Baseplate" and not mouse.Target:IsA("Model") then mouse.Target.Material = Enum.Material.ForceField end end)
so when I tried to convert it to FE compatible it doesn't give any error, and it won't work (even I tried to use ObjectValue)
FE Compatible script: (using RemoteEvents):
LocalScript
local mouse = game:GetService("Players").LocalPlayer:GetMouse() mouse.Button1Down:Connect(function() script.SelectedObject.Value = mouse.Target game.ReplicatedStorage.BlockChange:FireServer(script.SelectedObject) end)
Server script:
local objval = game.StarterPack.LocalBlockHandler.SelectedObject local re = game.ReplicatedStorage.BlockChange re.OnServerEvent:Connect(function(obj) if obj.Name ~= "Baseplate" and not obj:IsA("Model") then obj.Material = Enum.Material.ForceField end end)
I get this error when using the FE compatible: https://imgur.com/a/M9OW8L0
When a Local Player fires the Server, the Player Object will be sent first.
Just change
re.OnServerEvent:Connect(function(obj)
to
re.OnServerEvent:Connect(function(plr, obj)
You don't have to use plr, but index it so you can use obj.