Replicated to One Player Only

NO!
Just make client fire property and change that property on server

I’ve done something similar to that, and thankfully, I’ve fixed some issues. The only problem is replicating the clone/flashlight to the server so everyone sees it.

1 Like

I’ve done that, but the only problem I’m having now is replicating the flashlight to the server so everyone sees the flashlight.

you can do that by setting the flash light parent INSIDE a server script. So when player press F, you FireServer and make flashligth.Parent = plr

Please read my post
That literally what i said.
Dont invent a bycicle.
Just simply change property on server side

maybe u werent clear enough. Some people are learning how to script yet

Thought of that exact thing, but it feels like I’ll just go back to where I started…

1 Like

Listen: do something similar to this:

When player press F, “event:FireServer(plrFlashlight)”.

Inside server script.

event.OnServerEvent:Connect(function(plr, flashlight)
flashlight.Parent = plr.Character or plr.CharacterAdded:Wait()

end)

Sorry bad formatting. I am using cellphone

I’ll code that tomorrow morning. I’ll see if it works by then.

1 Like

If it doesn’t work, lemme know! :heart:

The old posted script (from the link) was set up using global variables.
This should be per person and a light (if it has one) should be seen by all.

--LocalScript..
local uis, db = game:GetService("UserInputService"), true
local remote = game:GetService("ReplicatedStorage")
	:WaitForChild("RemoteEvent")

uis.InputBegan:Connect(function(key)
	if key.UserInputType == Enum.UserInputType.Keyboard then
		if db and key.KeyCode == Enum.KeyCode.F then db = false
			remote:FireServer()
		end task.wait(2)
		db = true
	end
end)

--ServerScript.. item name is Flashlight
local remote = game:GetService("ReplicatedStorage")
	:WaitForChild("RemoteEvent")
local light, joint = nil, nil

remote.OnServerEvent:Connect(function(player)
	local character = player.Character or player.CharacterAdded:Wait()
	local existing = character:FindFirstChild("Flashlight")
	if existing then existing:Destroy()
	else light = game.ReplicatedStorage.Flashlight:Clone()
		light.Parent = character
		
		joint = Instance.new("Motor6D")
		joint.Part0 = character:FindFirstChild("Right Arm") or
			character:FindFirstChild("RightHand")
		joint.Part1 = light
		joint.C1 = CFrame.new(0, 1, 0)
		joint.Parent = joint.Part0
	end
end)

Do I need to pass the player through the FireServer, or is that already taken care of?

ServerScript should know the player as it was sent from that player’s ClientScript and player sending is always the 1st augment returned… If not get .LocalPlayer and send that as the 1st parameter.

Okay, so I don’t know if it’s a problem with me, or the script, but when I try to turn off the flashlight…

Studio crashes.

I thought that was odd… this isn’t set up to take anything off or turn anything off.
I followed the script given. If this is a flashlight tool, there is a whole different approach needed.

Not a flashlight tool, it’s a mesh duplicated into the character. Same thing as in the link for the script.

As for turning it on and off, I tinkered with it a bit to make it so.

Well how were you thinking of turning it on and off or taking it off at all?
You have a spotlight inside it?

I’m sure that had to do with them being joined and just removed on the 2nd click.
Unjoin them … then remove.

Since it does a FireServer, I decided to run a boolean through thanks to something I set up (F for Flashlight, F once to equip/true, F again to unequip/false)

It then transfers it over to the server, having it take care of everything. The decision it makes is thanks to the boolean I sent through.

(And yes, I do have a spotlight inside)

1 Like

Nah, it worked perfectly fine when I tested it. It was only after a few more runs that it just magically crashed.

Now I’m really concerned… I keep testing it and it keeps crashing me for no apparent reason. Prints don’t help.