I'm making a bucket/water system where the player can pick up water into their bucket by clicking "E". I want it to be that if the player leaves the water as in they stop touching it, then they can no longer pick up water. I'm not sure how I can implement something like that.
Finds if Player Touched
local Water = script.Parent
local Remote = game.ReplicatedStorage.InWater
local Players = game:GetService("Players")
local Pos = Players:GetPlayers()
local deb = false
Water.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
if deb == true then return end
local deb = true
local Ch = hit.Parent
print(Ch.Name)
local Player = Players:FindFirstChild(Ch.Name)
Remote:FireClient(Player)
print("Remote Fired")
end
wait(3)
deb = false
end)
Snippet of Local Script that finds if Player clicked E
Remote.OnClientEvent:Connect(function()
if Character.Bucket ~= nil then
Character.Bucket.IsInWater.Value = true
print(Character.Name.." Connected!")
PlayerGui:WaitForChild("Water").Enabled = true
UIS.InputBegan:Connect(function(input, proc)
if not proc and input.KeyCode == Enum.KeyCode.E then
local Water = Character.Bucket:GetChildren()
for i,v in pairs(Water) do
if v:IsA("Part") and v.Name == "Water1" and v.Visible.Value == false then
FirstLoad:FireServer(Player)
print("One Dip")
break
elseif v:IsA("Part") and v.Name == "Water2" and v.Visible.Value == false then
SecondLoad:FireServer(Player)
print("Two Dips")
break
elseif v:IsA("Part") and v.Name == "Water3" and v.Visible.Value == false then
ThirdLoad:FireServer(Player)
print("Three Dips")
break
end
end
end
end)
end
end)
