I am Having Problems using Mouse (I Shouldnt be Using Mouse, but for this posts sake pls ignore the fact that its Superseded by UserInputService). I Have made a RemoteEvent, a LocalScript and a Normal Script. I Want to Get Mouse.UnitRay Property but i cant. I Tried simplifying my script to check if its even firing and its not even FIRING.
also if i try to print/warn anything in local scripts OR even Server Scripts it doesnt. I Tried doing it on 2 seperate devices just to check if its a bug but its not working on both.
Client Script/Local Script
wait(10) -- so that everything loads
local Remote = game.ReplicatedStorage.RemoteEvent
local Mouse = game.Players.LocalPlayer:GetMouse()
Remote:FireServer(Mouse.Hit)
print("THIS DOES PRINT:CLIENT")
Server Side
local Remote = game.ReplicatedStorage.RemoteEvent
Remote.OnServerEvent:Connect(function(plr,Remains)
print(remains)
end)
print("THIS DOES PRINT : SERVER")
You should add an if statement to it so it’s like:
Client Script/Local Script
local Remote = game.ReplicatedStorage.RemoteEvent
local Mouse = game.Players.LocalPlayer:GetMouse()
if Mouse.hit then
wait(10) -- so that everything loads
Remote:FireServer()
print("THIS DOES PRINT:CLIENT")
end
Just include the print in the function and write “player” instead plr because you don’t have a variable called “plr” that refers to the actual player
Server Side
local Remote = game.ReplicatedStorage.RemoteEvent
Remote.OnServerEvent:Connect(function(player,Remains)
print(Remains)
print("THIS DOES PRINT : SERVER")
end)
Now it should works properly, i got to go right now if it’s not working I’ll try to look at it when I’m back home. I hope i helped you!
I am Thankful for your help though i have tried that before and tried force it print that on client and through remote on server but no avail. its ok i guess i will have to look for other solutions bye
The problem with the script above is that it checks if there’s a Mouse.hit and if none, do nothing. And the script stop’s and the remote event never fires. Because the script runs and ends before the player even loaded.
What you should do is attach it to a Mouse.MouseButton1Down event so that whenever the mouse clicks you can get a Mouse.hit
local Remote = game.ReplicatedStorage.RemoteEvent
local Mouse = game.Players.LocalPlayer:GetMouse()
Mouse.MouseButton1Down:Connect(function()
if Mouse.Hit then
Remote:FireServer(Mouse.Hit)
print("THIS DOES PRINT:CLIENT")
end
end)
So it Doesnt Work that way aswell.
Also now i have a 2nd issue.
Nothing Prints on the Local Script even if its outside function scope
like if i try to
warn("This Is Printed on to Output")
with no other code on a local script it doesnt print. Even on the Dev Console. i request you to check if its a bug.
i will be sending RBXL File Shortly. Thanks to Everyone on this Thread for your Help
These are the scripts the remote. It Doesnt work even though it should. i think its my Computer. Could you ty it in studio just for once. mousetest.rbxm (2.0 KB)
worst thing i that it doesnt even error for once( if its incorrect)