Ok so i tried to make a script to place a part wherever a player clicked. of course it has to use remote events for everyone to see it but when i click (yes i made sure both the remote event and the client script fire) it doesnt work. can someone help?

client script:

RE = game.ReplicatedStorage.RemoteEvent

player = game:GetService("Players").LocalPlayer

player:GetMouse().Button1Down:Connect(function(click)
	local Mousepos = player:GetMouse().hit.Position
	RE:FireServer(Mousepos)
end)

server scipt:

RE = game.ReplicatedStorage.RemoteEvent

local function trigger(player, Mousepos)
	local newpart = Instance.new("Part")
	print(Mousepos)
	local part = Instance.new("Part")
	part.Position = Mousepos
end

RE.OnServerEvent:Connect(trigger)

6 comments

0

can you put this code in a code block. it's hard to read

0

I'm new to this website idk how

0

Oh there

0

just found out i think it's because in the server script you didn't parent the part to the workspace

0

Also put the player:GetMouse() in a variable outside of the function because you're using it more than once

0

Thanks it worked!