UIS.InputBegan:Connect(function(Input,IsTyping)
if IsTyping then
return
elseif Input.UserInputType == Enum.UserInputType.MouseButton1 then
if Thrown == false then
Thrown = true
ThrowEvent:FireServer(Mouse.Hit,"Throw")
end
elseif Input.UserInputType == Enum.UserInputType.MouseButton2 then
if Thrown == true then
Thrown = false
wait(5)
ThrowEvent:FireServer(Mouse.Hit,"Retrieve")
end
end
end)
The retrieve state of my throwevent of my script is not firing, so i figured it’s probably due to my debounces. But on the off chance that my problem lies elsewhere.
Here’s the part of the server script where it picks up on the event(Excerpt):
Throw.OnServerEvent:Connect(function(Player,Direction,State)
elseif State == "Retrieve" then
print("Retrieve in motion")
end
end)
The print statement doesn’t run, How do I fix it?
you are not setting the debounce false again try this:
UIS.InputBegan:Connect(function(Input,IsTyping)
if IsTyping then
return
elseif Input.UserInputType == Enum.UserInputType.MouseButton1 then
if Thrown == false then
Thrown = true
ThrowEvent:FireServer(Mouse.Hit,"Throw")
wait(1) --how much sec u want
Thrown = false
end
elseif Input.UserInputType == Enum.UserInputType.MouseButton2 then
if Thrown == true then
Thrown = false
wait(5)
ThrowEvent:FireServer(Mouse.Hit,"Retrieve")
Thrown = true ---here
end
end
end)
The only thing I could see being wrong is that it’ll only work when you have thrown it already, did you try it out after throwing? If so, there may need to be some debugging to see what’s going on with the value of Thrown, try this code out so we can see what’s going on
UIS.InputBegan:Connect(function(Input,IsTyping)
if IsTyping then return end
print(Thrown)
if Input.UserInputType == Enum.UserInputType.MouseButton1 then
if not Thrown then
Thrown = true
ThrowEvent:FireServer(Mouse.Hit,"Throw")
end
elseif Input.UserInputType == Enum.UserInputType.MouseButton2 then
if Thrown then
Thrown = false
wait(5)
print("Sending receive to ThrowEvent")
ThrowEvent:FireServer(Mouse.Hit,"Retrieve")
end
end
end)
If it prints “Sending receive to ThrowEvent” then something is wrong with the remoteEvent
Just to endorse this response, use print statements before calling to server to verify where your script is going when called. It’ll help with debugging
Which one? The one in the if statement or the value of Thrown? What value did Thrown have when testing? Are you remembering to throw it and then retrieve?
Neither of them are running, the “Sending receive to throwevent” and “retrieve in motion”
of course, I am making thor’s hammer in which you have to throw before you can retrieve it. The throw part works btw, it’s the retrieval that’s the issue.
UIS.InputBegan:Connect(function(Input,IsTyping)
if IsTyping then return end
print(Thrown)
if Input.UserInputType == Enum.UserInputType.MouseButton1 then
-- Mjolnir Throw
if Thrown == false then
Thrown = true
ThrowEvent:FireServer(Mouse.Hit,"Throw")
Thrown = false
end
elseif Input.UserInputType == Enum.UserInputType.MouseButton2 then
-- Mjolnir Return
if Thrown == true then
Thrown = false
wait(5)
print("Sending receive to ThrowEvent")
ThrowEvent:FireServer(Mouse.Hit,"Retrieve")
end
end
end)