Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My script for placing blocks where a player clicks isnt working does anyone know why?

Asked by 3 years ago
Edited 3 years ago

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)
0
can you put this code in a code block. it's hard to read MarkedTomato 810 — 3y
0
I'm new to this website idk how Verse_NOVA 52 — 3y
0
Oh there Verse_NOVA 52 — 3y
0
just found out i think it's because in the server script you didn't parent the part to the workspace MarkedTomato 810 — 3y
View all comments (2 more)
0
Also put the player:GetMouse() in a variable outside of the function because you're using it more than once MarkedTomato 810 — 3y
0
Thanks it worked! Verse_NOVA 52 — 3y

Answer this question