i cant find the answer, this is my last resort.
the script wont work and this is the error
ServerScriptService.heal:10: attempt to index nil with 'Button1Down’
i cant figure out how to transfer variables through function to function.
this is the localscript
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local rep = game:GetService("ReplicatedStorage")
local cooldown = false
local allowed = false
mouse.KeyDown:connect(function(key)
local char = player.Character
if key == "e" then
if cooldown == false then
allowed = true
cooldown = true
for i, v in pairs(workspace.LocalVariables:GetChildren()) do
v.Value = false
end
wait(1)
cooldown = false
end
end
end)
mouse.Button1Down:connect(function()
if allowed == true then
local target = mouse.Target
if target.Parent:FindFirstChild("Humanoid") then
allowed = false
print(target)
rep.HealEvent:FireServer(target, mouse)
end
end
end)
and this is the regular script
local rep = game:GetService("ReplicatedStorage")
local allow = false
local maxtimes = 10
local health = 4
rep.HealEvent.OnServerEvent:Connect(function(player, target, mouse)
allow = true
mouse.Button1Down:Connect(function()
if allow == true then
local hum = target
allow = false
while wait(0.5) do
if maxtimes > 0 then
maxtimes -= 1
hum.Health += health
end
maxtimes = 10
end
end
end)
end)
the player is supposed to heal someone after they click on somebody.
any help please?