Hi! How can I make my fishing rod only work in water?
The player clicks and it casts out… but how do I get what terrain they player is clicking?
Hi! How can I make my fishing rod only work in water?
The player clicks and it casts out… but how do I get what terrain they player is clicking?
anyone know?
30 chssssssssssssssssssssss
You might be able to do Mouse.Target.Material, and see if it is water.
Ok, I will try
30 chsssssssssssssssssss
can you possibly send documentation or an example??
I’m having trouble finding it…
local hit, position, normal, material = getMouseHit()
if hit and hit:IsA("Terrain") then
print("Terrain material is " .. tostring(material))
end
whats getMouseHit() set to?
30 chssssssssssssssssssss
set a raycast from the player mouse position then check if the raycast hit water terrain and if it did allow fishig rod if not we won’t
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local player = Players.LocalPlayer
local mouse = player:GetMouse()
local function canFish()
local camera = workspace.CurrentCamera
local mouseRay = camera:ScreenPointToRay(mouse.X, mouse.Y)
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {player.Character}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
local raycastResult = workspace:Raycast(mouseRay.Origin, mouseRay.Direction * 1000, raycastParams)
if raycastResult then
local material = raycastResult.Material
return material == Enum.Material.Water
end
return false
end
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if input.UserInputType == Enum.UserInputType.MouseButton1 and not gameProcessed then
if canFish() then
-- your fishing cast rod add it it here
else
print("Can't Fish ROd")
end
end
end)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.